[Tex/LaTex] Chapterbib gives ‘citation undefined’ and all [?]

bibliographies

This is my first time posting. I have been struggling to include reference lists after each chapter included in my main .tex file. Though the .bbl file includes all the references, all the citations appear as [?] and no reference list is produced. I have run pdflatex, bibtex, pdflatex, pdflatex. I have tried using one .bib file and creating separate ones for each chapter. I know the .bib file is fine, because I initially had all the writing in the main file, but hadn't put in all the chapters and it compiled fine. When I added the second chapter I realized I needed to use \include{chap} to get separate lists.

Here is an example of my main file:

\documentclass[12pt]{report}

\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}{\singlespacing\normalfont\LARGE\bfseries}{\thechapter.}{16pt}{\LARGE}
\titleformat{\section}{\singlespacing\normalfont\Large\bfseries}{\thesection}{12pt}{\Large}
\titleformat{\subsection}{\singlespacing\bfseries}{\thesubsection}{12pt}{\Large}
\titleformat{\subsubsection}{\singlespacing\bfseries}{\thesubsubsection}{12pt}{}
\titlespacing*{\chapter}{0pt}{-19pt}{0pt}

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

\usepackage{setspace}
\usepackage{url}
\usepackage{textcomp}
\usepackage{amsmath}

\begin{document}
\tableofcontents

\include{chap1}
\include{chap2}

\end{document}

Here is an example of a chapter (the others are similar):

\chapter{Surface Energy Balance}
\label{else}
\doublespacing

Text \citet{Paterson10}.

\singlespacing
\bibliographystyle{plainnat}
\bibliography{bib1}

And the .bib entry:

@book{Paterson10,
    Author = {K. M. Cuffey and W. S. B. Paterson},
    Date-Added = {2015-06-01 15:34:50 +0000},
    Date-Modified = {2015-06-01 15:35:53 +0000},
    Publisher = {Academic Press},
    Title = {Physics of {G}laciers},
    Year = {2010}}

Best Answer

Since you are using natbib, you need specify its sectionbib option: \usepackage[sectionbib]{natbib}. Run pdflatex on the main file, which will generate aux files for each chapter. As @moewe indicates, open each aux file and run Bibtex on each of those files. This will generate bbl files for each chapter. Then rerun pdflatex of the main file. With the suggested change, your code works for me.

Related Question