3

I have a document using the memoir class, and I use the bibunits package to produce chapterwise bibliographies. This produces bibliographies as sections in each chapter, as expected, but in the table of contents, the bibliographies appear as chapters. I would like them to appear as sections there as well. How can I do this?

Here is a minimum working example:

\documentclass{memoir}
\usepackage[sectionbib]{bibunits}

\begin{document}

\bibliographyunit[\chapter]

\tableofcontents

\chapter{First chapter}
\section{First section}
This is the first chapter with one citation \cite{alonso1992phy}.
\putbib[references]

\end{document}

where the references.bib file is

@book{alonso1992phy,
   author = {Alonso, Marcelo and Finn, Edward J.},
   title = {Physics},
   year = {1992}
}

The resulting table of contents looks like this Table of contents

  • Apparently, bibunit does not take care of memoir settings. If you use book as class, there would be no entry in the ToC at all, by default. – user31729 Mar 30 '16 at 9:50
1

The memoir class has by default \bibsection defined being \@memb@bchap, an starred chapter which is added to the ToC if \bibintoc is used.

Redefining \bibsection to use \@memb@bsec is only a partial workaround, since this would add a numbered section as bibliography unit. A slight redefinition of \@memb@bsec takes care about this and will use either \section* or \section, depending on the state of \ifnumberedbib.

\documentclass{memoir}

\makeatletter

\newif\ifnumberedbib
\numberedbibfalse % False by default anyway

\AtBeginDocument{%    
\renewcommand{\@memb@bsec}{%
  \ifnumberedbib
  \section{\bibname}
  \else
  \section*{\bibname}%
  \fi
  \bibmark
  \ifnobibintoc\else
  \ifnumberedbib\else
  \phantomsection
    \addcontentsline{toc}{section}{\bibname}%
    \fi
    \fi
    \prebibhook
}

\renewcommand{\bibsection}{\@memb@bsec}
}

\makeatother
\usepackage[numbers]{natbib}
\usepackage[sectionbib]{bibunits}

\begin{document}

\bibliographyunit[\chapter]

\tableofcontents


\chapter{First chapter}
\section{First section}                           
This is the first chapter with one citation \cite{alonso1992phy}
\putbib[larsreferences]


\section{Second section}                           
This is the first chapter with one citation \cite{alonso1992phy}
\end{document}
  • One should note that for the real document there's a global bibliography -- the memoir settings for this usual bibliography should be saved before and restored later on. – user31729 Mar 30 '16 at 10:11
  • Thanks! That's great, and definitely solves the basic problem. However, I now see that I made my example a little too minimal, because ideally I would like to use this in combination with the natbib package with the numbers option, and that does not work. Do you have any idea why? – Lars Eirik Bø Mar 30 '16 at 11:16
  • @LarsEirikBø: You're complicating the situation. I'll have a look later on – user31729 Mar 30 '16 at 11:21
  • 1
    @LarsEirikBø: See the update -- the culprit is (again ;-)) memoir which does some redefinitions for natbib in a \AtBeginDocument{...} hook. I wrapped another \AtBeginDocument{...} around the changes from the original version and it seems to work. However, there might be other natbib conditions that are not fit. – user31729 Mar 30 '16 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.