[comp.text.tex] Mutiple Bibliographies

oliver@athena.mit.edu (James D. Oliver III) (06/05/91)

Is there a macro which will allow mutiple bibliographies in a single
document, for example, having a report with a separate bibliography for
each chapter?  Any pointers appreciated.

--
____________________________
	Jim Oliver  
	oliver@athena.mit.edu /	joliver@hstbme.mit.edu
	oliver%mitwccf.BITNET@MITVMA.MIT.EDU

spit@fys.ruu.nl (Werenfried Spit) (06/06/91)

In <OLIVER.91Jun5024515@hippocrates.mit.edu> oliver@athena.mit.edu (James D. Oliver III) writes:


>Is there a macro which will allow mutiple bibliographies in a single
>document, for example, having a report with a separate bibliography for
>each chapter?  Any pointers appreciated.

I wrote this one some time ago; I am not sure if
it is 100% proof (I remember there was a problem 
with referencing the same source in more than one
chapter)
Put in in the documentstyle

%%%%%%%%%%%%%%%%% bibliography %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Changes to put references after each chapter
% S.D. & W.S. (15-12-89)
%
% 1. defined mybibliography{bibdata-filename}{chapter-filename.bbl}
% 2. redefined \@bibitem with label consisting of chapter.biblabel
% 3. redefined \@citex to look for above-defined label, also in collapse part
% 4. redefined \thebibliography to define a new section instead of chapter

\def\mybibliography#1#2{\if@filesw\immediate\write\@auxout{\string
\bibdata{#1}}\fi\@input{#2.bbl}}

\def\@bibitem#1{\item\if@filesw \immediate\write\@auxout
       {\string\bibcite{\the\c@chapter.#1}{\the\c@bibcounter}}\fi\ignorespaces}

% Redefined in collapse, but can still be used
\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \def\@citea{}\@cite{\@for\@citeb:=#2\do
  {\def\@cbib
    {\the\c@chapter.\@citeb}\@citea\def\@citea{,\penalty\@m}\@ifundefined
    {b@\@cbib}{{\bf ?}\@warning
    {Citation `\@cbib' on page \thepage \space undefined}}%
  \hbox{\csname b@\@cbib\endcsname}}}{#1}}

\def\thebibname{References}
\def\thebibliography#1{\section*{\thebibname}
 \markboth{\thebibname}{\thebibname}
 \addcontentsline{toc}{section}{\protect\numberline{\null}\thebibname}
 \list{[\arabic{bibcounter}]}{\settowidth\labelwidth{[#1]} % evt \arabic{chapter}. ervoor
  \leftmargin\labelwidth \itemsep 0pt plus 1pt \parsep 0pt \usecounter{bibcounter}}
 \def\newblock{\hskip 0.5em plus 0.3em minus -0.05em}
 \small \sloppy \sfcode`\.=1000 \relax}
\let\endthebibliography=\endlist
        
% Collapse citation numbers to ranges.  Non-numeric and undefined labels
% are handled.  No sorting is done.  E.g., 1,3,2,3,4,5,foo,1,2,3,?,4,5
% gives 1,3,2-5,foo,1-3,?,4,5
% Here also \@cbib replaces \@citeb for references after each chapter

\newcount\@tempcntc
\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \@tempcnta\z@\@tempcntb\m@ne\def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\def\@cbib{\the\c@chapter.\@citeb}\@ifundefined
      {b@\@cbib}{\@citeo\@tempcntb\m@ne\@citea\def\@citea{,}{\bf ?}\@warning
         {Citation `\@cbib' on page \thepage \space undefined}}%
       {\setbox\z@\hbox{\global\@tempcntc0\csname b@\@cbib\endcsname\relax}%
\ifnum\@tempcntc=\z@ \@citeo\@tempcntb\m@ne\@citea\def\@citea{,}\hbox{\csname b@\@cbib\endcsname}%
     \else
      \advance\@tempcntb\@ne
      \ifnum\@tempcntb=\@tempcntc
      \else\advance\@tempcntb\m@ne\@citeo
      \@tempcnta\@tempcntc\@tempcntb\@tempcntc\fi\fi}}\@citeo}{#1}}
\def\@citeo{\ifnum\@tempcnta>\@tempcntb\else\@citea\def\@citea{,}%
  \ifnum\@tempcnta=\@tempcntb\the\@tempcnta\else
   {\advance\@tempcnta\@ne\ifnum\@tempcnta=\@tempcntb \else \def\@citea{--}\fi
    \advance\@tempcnta\m@ne\the\@tempcnta\@citea\the\@tempcntb}\fi\fi}

\newif\if@restonecol
\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
\columnseprule \z@
\columnsep 35pt\twocolumn[\@makeschapterhead{Index}]
 \@mkboth{Index}{Index}\thispagestyle{plain}\parindent\z@
 \parskip\z@ plus .3pt\relax\let\item\@idxitem}
\def\@idxitem{\par\hangindent 40pt}
\def\subitem{\par\hangindent 40pt \hspace*{20pt}}
\def\subsubitem{\par\hangindent 40pt \hspace*{30pt}}
\def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
\def\indexspace{\par \vskip 10pt plus 5pt minus 3pt\relax}

boogaard@fys.ruu.nl (Martin vdBoogaard) (06/07/91)

In <OLIVER.91Jun5024515@hippocrates.mit.edu> oliver@athena.mit.edu (James D. Oliver III) writes:

% Is there a macro which will allow mutiple bibliographies in a single
% document, for example, having a report with a separate bibliography for
% each chapter?

Yes, there is a style (option) file that does something like that. It's
called chapterbib.sty and can be found e.g. in pub/tex/latex-style at
clarkson (128.153.12.3). I've tried it once and it seemed to do a good
job.


Good luck.

Martin J. van den Boogaard                 |        boogaard@fys.ruu.nl
-----------------------------------------------------------------------
Dept. of Atomic & Interface Physics        |            the Netherlands
Debye Institute--Utrecht University        |        phone +31 30 532904
P.O. Box 80.000, NL-3508 TA Utrecht        |        fax   +31 30 543165
-----------------------------------------------------------------------
some days you wake up and immediately start to worry. nothing in
particular is wrong, it's just the suspicion that forces are aligning
quietly and there will be trouble.            --           Jenny Holzer
-----------------------------------------------------------------------