30
votes

I am helping a colleague with his PhD thesis and we need to present the bibliography at the end of each chapter.

The question is: does anyone have a minimal working example for this case using latex+bibtex?

The current document structure that we use is the following:

main.tex
chap1.tex
chap2.tex
...
chapn.tex
biblio.bib

Where main.tex contains packages, document declarations, macros and \includes for each chapter. biblio.bib is the only bibtex file (I think is easier to have all citations in one place).

We have searched and tried with different latex packages, reading and following their documentation. Specifically, bibitems and chapterbib.

bibitems successfully generates bu*.aux files, but when running bibtex for each one of them, an error occurs since there is no \bibdata element in the .aux file.

chapterbib also generates a .aux file, but bibtex finishes with an error caused by using multiple \bibliography{file} in the .tex files (one per chapter).

Some coworkers suggested using a separate bibtex file for each chapter, which could be a problem of maintenance in the future when citing the same publications in different chapters.

We will like to continue having this document structure, if possible. So, if anyone could shed some light to this problem, we will appreciate it.

Thanks.


Update: MWE found Thanks to Habi for the help, here is a working example:

With the document structure mentioned above:

% main.tex
\documentclass{report}
\usepackage{url}
\usepackage{natbib}
\usepackage{chapterbib}

\begin{document}

\include{chap1}
\include{chap2}
% other chapters ...

\end{document}

% chap1.tex
\chapter{one chapter}
text~\cite{paper1}
text~\cite{paper2}
% don't forget:
\bibliographystyle{plainnat}
\bibliography{biblio}

% chap2.tex
\chapter{another chapter}
text~\cite{paper2, paper3}
% don't forget, again:
\bibliographystyle{plainnat}
\bibliography{biblio}

% biblio.bib
@Article{paper1,
  author =       {John Smith},
  title =        {A title},
  journal =      {A Journal},
  year =         {2010}
}
@Article{paper2,
  author =       {John Doe},
  title =        {A paper},
  journal =      {Another journal},
  year =         {2009}
}
@Article{paper3,
  author =       {Yuppie Networking},
  title =        {My paper},
  journal =      {The best journal},
  year =         {2000}
}

Finally, to generate the document:

#!/bin/bash
latex main.tex
for auxfile in chap*.aux
do
    bibtex `basename $auxfile .aux`
done
latex main.tex
latex main.tex
2
If you'd like to create a working example, I believe this stuff is built in to TeXnicCenter, a windows IDE for TeX documents.Greg D
chapterbib's issue could be solved by putting a \bibliography in main.tex only, could it not?Andrew McGregor
I would swear that we've done this before...and after much searching I find stackoverflow.com/questions/2503555/…. Whew. No shame to the OP for not finding that duplicate.dmckee --- ex-moderator kitten

2 Answers

12
votes

some time ago i've quickly jotted down some notes on chapterbib. do they help you?

http://wiki.davidhaberthuer.ch/latex#chapterbib

2
votes

That one is a TeX FAQ item:

A separate bibliography for each “chapter” of a document can be provided with the package chapterbib (which comes with a bunch of other good bibliographic things). The package allows you a different bibliography for each \included file (i.e., despite the package’s name, the availability of bibliographies is related to the component source files of the document rather than to the chapters that logically structure the document). [...]