# \bibentry problem with chapterbib package

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}


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 by bibtex 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 the sectionbib option of chapterbib. EDTI See below for how to work around this

# book.cls

Main part

Included 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}
\nobibliography*

\chapter{Light}
A full in-text cite of \bibentry{einstein1911}.\\
A regular citation: \citep{einstein1911}.
\bibliographystyle{apalike}
\bibliography{mytestbib}
\end{filecontents}

\documentclass{book}
\usepackage{filecontents}
\usepackage{bibentry}
\usepackage{natbib}
\usepackage[sectionbib]{chapterbib}
\nobibliography*

\begin{document}
\bibliographystyle{apalike}

A full in-text cite of \bibentry{einstein1911}.\\
A regular citation: \citep{einstein1911}.

\include{testchap}

\bibliography{mytestbib}
\end{document}


# scrbook.cls

For scrbook class the above will work fine, unless you pass the sectionbib option to chapterbib. This is because the sectionbib option attempts to patch the definition of thebibliography, but scrbook changes the standard definition. However, the effect of the sectionbib option may be optianed by issuing

\KOMAoption{bibliography}{leveldown}


in the preamble, which switches bibliogrpahies to be sections, and then \bib@leveldownfalse, appropriately escaped, before the main bibliography to make this a 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}
\nobibliography*

\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{bibentry}
\usepackage{natbib}
\usepackage{chapterbib}
\nobibliography*

\KOMAoption{bibliography}{leveldown}

\begin{document}
\bibliographystyle{apalike}

A full in-text cite of \bibentry{einstein1911}.\\
A regular citation: \citep{einstein1911}.

\include{testchap}

\makeatletter
\bib@leveldownfalse
\makeatother
\bibliography{mytestbib}
\end{document}

• Just want to add a comment because it took me some time to figure out what was preventing this solution from working for me. \bibentry is for some reason not compatible with the use of usepackage[french]{babel}. See tex.stackexchange.com/questions/130344/… Aug 13 '20 at 9:34