0

Let's consider the following directory structure:

.
├── contents
│   ├── backmatter
│   │   ├── appendix.bib
│   │   └── appendix.tex
│   ├── frontmatter
│   │   ├── preface.bib
│   │   └── preface.tex
│   └── mainmatter
│       ├── chapter1.bib
│       ├── chapter1.tex
│       ├── chapter2.bib
│       └── chapter2.tex
└── main.tex

And the following main file:

% main.tex
\documentclass[oneside, 10pt]{book}

\usepackage[T1]{fontenc}
\usepackage[sf = false, tt = false]{libertine}
\usepackage{lipsum}
\usepackage[sectionbib]{chapterbib}
\usepackage{hyperref}

\begin{document}
\frontmatter
\include{contents/frontmatter/preface}
\mainmatter
\include{contents/mainmatter/chapter1}
\include{contents/mainmatter/chapter2}
\backmatter
\include{contents/backmatter/appendix}
\end{document}

Question: How to use the chapterbib package and compile the whole thing so that one bibliography section gets generated for every chapter at the end of every chapter? (I would like the explanation with and without natbib if that changes anything)


The preface:

% preface.tex
\chapter{Preface}

\section{Preface first section}
\lipsum[1]\cite{preface:ref1}

\section{Preface second section}
\lipsum[1]\cite{preface:ref2}

\section{Preface third section}
\lipsum[1]\cite{preface:ref3}

\bibliographystyle{alpha}
\bibliography{preface} 

and:

% preface.bib
@article{preface:ref1,
    author  = {Someone}, 
    title   = {Preface1},
    journal = {Journal},
    year    = 2000,
}

@article{preface:ref2,
    author  = {Someone}, 
    title   = {Preface2},
    journal = {Journal},
    year    = 2000,
}

@article{preface:ref3,
    author  = {Someone}, 
    title   = {Preface3},
    journal = {Journal},
    year    = 2000,
}

The first chapter:

% chapter1.tex
\chapter{First chapter}

\section{First chapter first section}
\lipsum[1]\cite{chapter1:ref1}

\section{First chapter second section}
\lipsum[1]\cite{chapter1:ref2}

\section{First chapter third section}
\lipsum[1]\cite{chapter1:ref3}

\bibliographystyle{alpha}
\bibliography{chapter1} 

and:

% chapter1.bib
@article{chapter1:ref1,
    author  = {Someone}, 
    title   = {FirstChapter1},
    journal = {Journal},
    year    = 2000,
}

@article{chapter1:ref2,
    author  = {Someone}, 
    title   = {FirstChapter2},
    journal = {Journal},
    year    = 2000,
}

@article{chapter1:ref3,
    author  = {Someone}, 
    title   = {FirstChapter3},
    journal = {Journal},
    year    = 2000,
}

The second chapter:

% chapter2.tex
\chapter{Second chapter}

\section{Second chapter first section}
\lipsum[1]\cite{chapter2:ref1}

\section{Second chapter second section}
\lipsum[1]\cite{chapter2:ref2}

\section{Second chapter third section}
\lipsum[1]\cite{chapter2:ref3}

\bibliographystyle{alpha}
\bibliography{chapter2} 

and:

% chapter2.bib
@article{chapter2:ref1,
    author  = {Someone}, 
    title   = {SecondChapter1},
    journal = {Journal},
    year    = 2000,
}

@article{chapter2:ref2,
    author  = {Someone}, 
    title   = {SecondChapter2},
    journal = {Journal},
    year    = 2000,
}

@article{chapter2:ref3,
    author  = {Someone}, 
    title   = {SecondChapter3},
    journal = {Journal},
    year    = 2000,
}

The appendix:

% appendix.tex
\chapter*{Appendix}

\section*{Appendix first section}
\lipsum[1]\cite{appendix:ref1}

\section*{Appendix second section}
\lipsum[1]\cite{appendix:ref2}

\section*{Appendix third section}
\lipsum[1]\cite{appendix:ref3}

\bibliographystyle{alpha}
\bibliography{appendix} 

and:

% appendix.bib
@article{appendix:ref1,
    author  = {Someone}, 
    title   = {Appendix1},
    journal = {Journal},
    year    = 2000,
}

@article{appendix:ref2,
    author  = {Someone}, 
    title   = {Appendix2},
    journal = {Journal},
    year    = 2000,
}

@article{appendix:ref3,
    author  = {Someone}, 
    title   = {Appendix3},
    journal = {Journal},
    year    = 2000,
}
Vincent
  • 5,257

0 Answers0