4

I have been struggling a lot with this problem now. Hopefully somebody can help me. I want to create a document with chapterwise bibliography, so I use \usepackage{chapterbib} together with \usepackage[sectionbib]{natbib}:

\documentclass{report}

\usepackage{chapterbib}
\usepackage[sectionbib]{natbib}

\begin{document}

\include{chapter1}

\end{document}

where the file chapter1.tex (in the same folder) is

\chapter{Chapter 1}
this is chapter 1~\cite{Article1}

\bibliographystyle{plain}
\bibliography{references}

and the file references.bib (also in the same folder) reads

@article{Article1,
    author = {Author1},
    journal = {J. Art.},
    pages = {1906--1911},
    title = {{This is the first article}},
    volume = {12},
    number = {3},
    year = {2012}
}

While the second citation (Article2) is displayed as expected, there is a question mark where the first citation should be: https://www.dropbox.com/s/zhtuz9nw0otuw6i/Include.pdf?dl=0

What am I doing wrong?

8
  • What I forgot to mention: It does work if you substitude \include by \input. But then, chapterbib does not work anymore. Dec 11, 2015 at 16:54
  • 1
    you should use \include with all the chapters and run bibtex separately on each chapter to generate the separate bibliographies Dec 11, 2015 at 17:12
  • This is what I have done several times. Does not seem to work. Dec 14, 2015 at 11:45
  • If you have a version that you think should work but does not, edit the question above to be that code (so move \chapter out of the main file) and then say exactly how it "does not work" show exactly how you called bibtex and what error log you got Dec 14, 2015 at 11:54
  • 2
    I found the problem now. I didn't know that TeXstudio uses bibtex always on the main document, even if chapter1.tex is active. I had to run bibtex via the command window to make it work. Strange. Thanks anyway. Dec 14, 2015 at 15:55

2 Answers 2

4

You should use \include with all the chapters and run bibtex separately on each chapter to generate the separate bibliographies, one for each chapter.

1
  • This is what I have done several times. Does not seem to work. Dec 14, 2015 at 9:50
1

The problem was that my LaTeX editor, TeXstudio, does not run bibtex on the active document, but always on the main document. However, bibtex must be run on the sub-document to generate (what was in my case called) chapter1.bbl. Running bibtex via the command window solved the problem.

2
  • If you happen to use texlive (and not miktex) then compiling on the code with latexmk - pdf master.tex ought to run bibtex automatically on each separate part
    – daleif
    Dec 14, 2015 at 16:40
  • Great hint! But not miktex? Is says "because it is part of MacTeX and MikTeX" on mg.readthedocs.io/latexmk.html
    – user236748
    Feb 20, 2022 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .