I'm using chapterbib package to generate a bibliography for each chapter. But the compilation fails.
Here is the content of my principal.tex file:
\documentclass[phd]{theseUL}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
%\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage{amsfonts}
\usepackage{url}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{color}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{topcapt}
\usepackage{setspace}
\usepackage{rotfloat}
\usepackage[square,sort,comma, authoryear]{natbib}
\usepackage{chapterbib}
\begin{document}
\part{Contexte général et état de l'art}
\include{../chap1_introduction/chap1_introduction}
\input{../chap2_definitions/chap2_definitions}
\end{document}
Here is the content of chap1_introduction.tex
\chapter{Introduction} %%This is chapter 1
\phantomsection\addcontentsline{toc}{chapter}{Introduction}
Text
\bibliographystyle{authordate1}
\bibliography{principal}
And so for the content of chap2_definitions.tex
\chapter{Definition} %%This is chapter 2
\phantomsection\addcontentsline{toc}{chapter}{Definition}
Text
\bibliographystyle{authordate1}
\bibliography{principal}
This is how I compile my documents:
- pdflatex principal.tex (success)
- pdflatex principal.tex (success)
- bibtex principal (2 errors, I guess it is normal: see output #1)
- bibtex ../chap1_introduction/chap1_introduction (see output #2)
- bibtex ../chap2_definitions/chap2_definitions (see output #3)
- pdflatex principal.tex
- pdflatex principal.tex
Output #1
XXXX@IFTEaigny2:~/Phd/principal$ bibtex principal
This is BibTeX, Version 0.99c (TeX Live 2009/Debian)
The top-level auxiliary file: principal.aux
The style file: authordate1.bst
Illegal, another \bibstyle command---line 51 of file principal.aux
: \bibstyle
: {authordate1}
I'm skipping whatever remains of this command
Illegal, another \bibdata command---line 52 of file principal.aux
: \bibdata
: {principal}
I'm skipping whatever remains of this command
Database file #1: principal.bib
Warning--to sort, need author or key in GrownUpDigital2009
Warning--empty author in GrownUpDigital2009
Warning--empty journal in GrownUpDigital2009
Warning--empty journal in Torres2008
(There were 2 error messages)
Output #2
XXXX@IFTEaigny2:~/Phd/principal$ bibtex principal
This is BibTeX, Version 0.99c (TeX Live 2009/Debian)
The top-level auxiliary file: ../chap1_introduction/chap1_introduction.aux
The style file: authordate1.bst
I couldn't open database file chap1_introduction.bib
---line 43 of file ../chap1_introduction/chap1_introduction.aux
: \bibdata{chap1_introduction
: }
I'm skipping whatever remains of this command
I found no database files---while reading file ../chap1_introduction/chap1_introduction.aux
Warning--I didn't find a database entry for "Downes2005"
Warning--I didn't find a database entry for "Hadjerrouit2005"
Warning--I didn't find a database entry for "Hadjerrouit2007"
Warning--I didn't find a database entry for "Wilson2007"
Warning--I didn't find a database entry for "Seffah2002"
Warning--I didn't find a database entry for "Torres2008"
Warning--I didn't find a database entry for "Downes2004"
Warning--I didn't find a database entry for "GrownUpDigital2009"
(There were 2 error messages)
output #3 is same than output #2
principal.bib is the entire citation databse for the whole document and is in /principal; so I have principal/principal.bib.
Should I compile the chapters bibtex from the chapter subdirectory, or from the principal subdirectory as I did? I tried both withe the same result.
Thank you.
Best Answer
I already answered here on LaTeX-Community, but also here my answer. I can see that you use
\input
for including the chapters in this line:However, you should use
\include
instead, this way you would get .aux files for each chapter which can be processed. Otherwise, with\input
, you would need\cbinput
or thecbunit
environment. However,\include
is strongly recommended. You use chapters, for sure starting a new page, so\include
would be fine.Here's also a solution: chapterbib | References following each Chapter. Also there, the solution was using
\include
but additionally having the files in the same directory.