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 \include
s 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