It may be uncomfortable to access bibliographical data several hundred pages from the reference. In many books there are other reasons to have separate bibliography per chapter, for example in collections of papers. This post describes my attempts to do this using a typical text typeset in LaTeX with bibliographies formatted by BibTeX.
Like for most other LaTeX-related problems, the first resource where I find information is the UK TeX FAQ. Its page about this problem lists two packages – chapterbib and bibunits. So I began reading their documentation and adjusting the document for them.
The main use of chapterbib is by having separate bibliographies per \included file. It has two problems in my case – I don’t use \include since it’s not needed with modern computers, but this would require only trivial changes (my text doesn’t need parts of two chapters on the same page, unlike some journals); another problem is the need to specify \bibliographystyle and \bibliography in each chapter. Since I prefer to specify such data only once (the bibliography style only in a document class), I could modify \include to add these commands. This doesn’t look elegant enough and did not work when I tried. The package works also without \include, but it also does not work in my case.
Then I tried bibunits. I added the following code to the preamble of the document:
\usepackage[sectionbib]{bibunits} \defaultbibliographystyle{plainurl} \defaultbibliography{example-bibliography} \newcommand{\bibinput}[1]{% \begin{bibunit} \input{#1} \putbib \end{bibunit}}
and replaced \input by \bibinput to input the chapters. To call BibTeX, instead of the C shell scripts recommended by the package documentation, I used the following Bourne shell command:
for i in `seq 1 9`; do bibtex bu$i; done
where 9 is the number of \bibinputs or any larger integer.
This produced appropriate output, although with the header of the bibliography on the following page. I corrected it by redefining \@mkboth in the environment making the bibliography:
\makeatletter \let\oldtb=\thebibliography \renewcommand{\thebibliography}{% \renewcommand{\@mkboth}[2]{}% \oldtb} \makeatother
With this change the document looks correct when each chapter has its own bibliography.
