# Simple example of per-chapter citation

I have been assigned to make a book out of student paper and I want to make a chapter for each paper and have the bibliography at the end of each chapter. So I tried the following but do not get the proper output. My folder structure is like this

main.tex
--->chapter1
c1.tex
b1.bib
--->chapter2
c2.tex
b2.bib


main.tex

\documentclass{report}

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

\begin{document}
hello

\input{chapter1/c1}
\input{chapter2/c2}
\end{document}


c1.tex

\chapter{chapter 1}
hi this is chpater 1 ~\cite{b1}

\bibliographystyle{plainnat}
\bibliography{chapter1/b1}


b1.bib

@inproceedings{b1,
title={chaptrer 1 book},
author={Gentry, Craig},
booktitle={Proceedings of the forty-first annual ACM symposium on Theory of computing},
pages={169--178},
year={2009}
}


c2.tex

\chapter{chapter 2}
hi this is chapter 2~\cite{b2}

\bibliographystyle{plainnat}
\bibliography{chapter2/b2}


b2.bib

@inproceedings{b2,
title={chaptrer 2 book},
author={Gentry, Craig},
booktitle={Proceedings of the forty-first annual ACM symposium on Theory of computing},
pages={169--178},
year={2009}
}


i am using texwork and engine is pdfLatex+makeIndex+BibTex . and also i should mention there is multiple .bib files.

1 . what how should i reference in bib file \bibliography{chapter2/b2} or just \bibliography{b2} ?

1. i think after running main by pdfLatex should some aux file for each chapter be generated but there is no aux file in folders chapter1 and chapter2. why ?

Update: I run the main file as following :

padfLatex
BibTex
pdfLatex


chapter one is correct But chapter two file citation is like [?] and also shows bibliography of chapter 1 instead of chapter 2.

and this is content of main.aux

\relax
\citation{b1}
\bibstyle{plainnat}
\bibdata{chapter1/b1}
\@writefile{toc}{\contentsline {chapter}{\numberline {1}chapter 1}{1}\protected@file@percent }
\bibcite{b1}{{1}{2009}{{Gentry}}{{}}}

\citation{b2}
\bibstyle{plainnat}
\bibdata{chapter2/b2}
\@writefile{toc}{\contentsline {chapter}{\numberline {2}chapter 2}{3}\protected@file@percent }

• Welcome to TeX SX! biblatex defines the refsection environments, which gives you the possibility to have bibliographies per chapter. – Bernard Feb 26 at 22:05