[Tex/LaTex] chapterbib creates reference but with

bibliographiescitingnatbib

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}

Best Answer

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}