# chapterbib creates reference but with?

I am trying to use chapterbib and natbib to create different bibliographies for every chapter. When I compile my master document some of the citations show (?) even though the references are in the bibliography. Below is a minimum example. With \usepackage{chapterbib} commented out everything is fine, but if it is included the document shows literature (?) but with testarticle in the bibliography.

\documentclass{article}
\usepackage{filecontents}

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

\begin{filecontents*}{article_I_text.tex}
literature \cite{testref}.
\end{filecontents*}

\begin{filecontents*}{references.bib}
@article{testref,
title={testarticle}}
}
\end{filecontents*}

\begin{document}

\include{article_I_text}
\bibliographystyle{plain}
\bibliography{references}
\end{document}


The manual says:

1 Normal use: Put \bibliographystyle and \bibliography commands in each \included file. Run LATEX; run BibTEX on each included file; run LATEX; run LATEX.

So you should do something like this:

\documentclass{article}
\usepackage{filecontents}

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

\begin{filecontents*}{article_I_text.tex}
literature \cite{testref}.
\bibliographystyle{plain}
\bibliography{references}
\end{filecontents*}

\begin{filecontents*}{references.bib}
@article{testref,
title={testarticle}}
}
\end{filecontents*}

\begin{document}

\include{article_I_text}
\end{document}


You can also change the \include with \input as a quick solution (Probably not the best, you should check your needs). There might be some useful information here: When should I use \input vs. \include?

\documentclass{article}
\usepackage{filecontents}

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

\begin{filecontents*}{article_I_text.tex}
literature \cite{testref}.
\end{filecontents*}

\begin{filecontents*}{references.bib}
@article{testref,
title={testarticle}}
}
\end{filecontents*}

\begin{document}

\input{article_I_text}
\bibliographystyle{plain}
\bibliography{references}
\end{document}