In my document I want to create a separate bibliography for each chapter. This works fine by using the chapterbib package. However, \bibentry does not work anymore in included files when invoking the chapterbib package. The MWE shows that the full cite is present in the main document, but does not show in the chapter.
\begin{filecontents}{mytestbib.bib}
@Article{einstein1911,
author = "Albert Einstein",
title = "On The influence of gravitation on the propagation of light",
journal = "Annalen Phys.",
volume = "35",
pages = "898-908",
year = "1911"}
\end{filecontents}
\begin{filecontents}{testchap.tex}
\chapter{light}
A full in-text cite of \bibentry{einstein1911}.\\
A regular citation: \citep{einstein1911}.
\bibliographystyle{apalike}
\bibliography{mytestbib}
\end{filecontents}
\documentclass{scrbook}
\usepackage{filecontents}
\usepackage{natbib}
\usepackage{bibentry}
\usepackage[sectionbib]{chapterbib}
\nobibliography*
\begin{document}
A full in-text cite of \bibentry{einstein1911}.\\
A regular citation: \citep{einstein1911}.
\include{testchap}
\bibliographystyle{apalike}
\bibliography{mytestbib}
\end{document}
Best Answer
The subfiles need to have a
\nobibliography*
command included so that\bibentry
works. In addition, you should really put the\bibliographystyle
of the main file before any file inclusions. In your case it is not too important, but if you had different styles in the subfiles it would give a problem - each of the aux files for of the included files is read bybibtex
and so it meets multiple\bibstyle
commands, only the first one takes effect, hence the need of ordering the main file correctly.This all works fine for the standard book class, however with
scrbook
you can not use thesectionbib
option ofchapterbib
. EDTI See below for how to work around thisbook.cls
Main part
Included chapter
scrbook.cls
For
scrbook
class the above will work fine, unless you pass thesectionbib
option tochapterbib
. This is because thesectionbib
option attempts to patch the definition ofthebibliography
, butscrbook
changes the standard definition. However, the effect of thesectionbib
option may be optianed by issuingin the preamble, which switches bibliogrpahies to be sections, and then
\bib@leveldownfalse
, appropriately escaped, before the main bibliography to make this a chapter.