11

I've been using example 3.11.4 of the biblatex documentation to generate a per-chapter bibliography at the end of my thesis. It works great, until I try to make my introduction into an unnumbered chapter. Then, the introduction does not appear in the bibliography. Here's a MWE:

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}

\cite{A01}

\chapter{Chapter 1}

\cite{A01,B02}

\backmatter

\printbibheading
\bibbysegment[heading = bibintoc]

\end{document}

I found a work-around, using a refsection for the unnumbered Introduction. Here's a MWE of the workaround:

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]

\end{document}

I was content with this until I added an unnumbered Conclusion with citations. Then the code breaks down and biblatex returns a nested refsections error. Here's the MWE for that:

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\chapter*{Conclusion}
\begin{refsection}
\cite{C03}
\end{refsection}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]

\end{document}

Any ideas how to solve this? Or, even better, how to properly implement \chapter* with example 3.11.4 of the biblatex doc?

Thanks in advance for the help!

3 Answers 3

8

You can invoke \newrefsegment and \citereset manually in the unnumbered chapters:

\chapter*{Introduction}
\newrefsegment
\citereset

but the titles for the bibliography segments can't be formatted consistently. There are various ways around this. Here we handle everything with patches to both \chapter and \chapter*.

\documentclass{book}
\usepackage[sorting=none,refsegment=chapter,citereset=chapter]{biblatex}
\usepackage{nameref}

\makeatletter
% Extend biblatex's \chapter patch to \chapter* and save data for titles
\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1%
        \csdef{subbib:\therefsection\therefsegment}{%
          Chapter~\ref{refsegment:\therefsection\therefsegment}}}
       {}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1%
        \csdef{subbib:\therefsection\therefsegment}{%
          \nameref{refsegment:\therefsection\therefsegment}}}
       {}{\blx@err@patch{\string\@makeschapterhead}}}}
\makeatother
\defbibheading{subbibliography}{%
  \section*{References for \csuse{subbib:\therefsection\therefsegment}}}

\addbibresource{biblatex-examples.bib}
\begin{document}
\tableofcontents
\chapter*{Introduction}
\cite{reese}
\chapter{First chapter}
\cite{companion}
\chapter*{Unnumbered chapter}
\cite{glashow,weinberg}
\chapter{Second chapter}
\cite{glashow}
\chapter*{Conclusion}
\cite{reese}
\printbibheading[heading=bibintoc]
\bibbysegment[heading=subbibliography]
\end{document}

enter image description here

This approach also works for reference sections by chapter.

\documentclass{book}
\usepackage[sorting=none,refsection=chapter]{biblatex}
\usepackage{nameref}

\makeatletter
% Extend biblatex's \chapter patch to \chapter*, save data for titles
\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1\csdef{subbib:\therefsection}{Chapter~\ref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1\csdef{subbib:\therefsection}{\nameref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makeschapterhead}}}}
\makeatother
\defbibheading{subbibliography}{\section*{References for \csuse{subbib:\therefsection}}}

\addbibresource{biblatex-examples.bib}
\begin{document}
...
\printbibheading[heading=bibintoc]
\bibbysection[heading=subbibliography]
\end{document}
4
  • This is what I had in mind. However, this solution seems to break \citereset. Any ideas how to fix that?
    – Kpantzas
    Commented Aug 30, 2012 at 12:28
  • @Kpantzas That seems unlikely. Switching the style to verbose and playing around with the citereset settings or \citereset in the above document doesn't demonstrate any issues.
    – Audrey
    Commented Aug 30, 2012 at 13:06
  • Well then I guess I haven't understood citereset. I thought that it was used to reset citations so that they would start from [1] after each reset (in this case each chapter). This is not the behavior I'm getting with your example. Though now that I think about it, this would be incompatible with refsegment and I should use refsection instead... any thoughts about that?
    – Kpantzas
    Commented Aug 30, 2012 at 14:41
  • 1
    @Kpantzas \citereset only resets the citation trackers. For independent labelnumbers you should be using reference sections, not segments. I've updated the post to demonstrate the approach with refsection=chapter.
    – Audrey
    Commented Aug 30, 2012 at 15:29
6

You have to use \endrefsegment to manually terminate the last segment before the unnumbered "Conclusion" chapter.

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\endrefsegment

\chapter*{Conclusion}
\begin{refsection}
\cite{C03}
\end{refsection}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]
\printbibliography[section=2,heading=bibintoc2]

\end{document}

enter image description here

While this solves your immediate problem, your workaround of using refsections for the Introduction and Conclusion results in completely independent bibliography labels for these chapters (note how the work of C. Cuthor is assigned the label "1" in the Conclusion). The following solution works only with refsegments (and hereby achieves labels unique for the whole document):

  • Don't use the starred version \chapter* but \chapter also for the Introduction and Conclusion. This way, a (positive) refsegment number will be assigned to these chapters, and their respective references can be printed using \bibbysegment.

  • Use \frontmatter, \mainmatter and \backmatter to make the Introduction and Conclusion non-numbered chapters. (Actually, use \boolfalse{@mainmatter} instead of \frontmatter to avoid switching to Roman page numbering.)

  • Declare new counters to store the value of \therefsegment after the front- resp. the mainmatter, and use these counters in a new definition of the bibintoc2 heading to achieve the different format for front-/main-/backmatter references.


\documentclass{book}

\usepackage[sorting=none,style =numeric,refsegment=chapter,citereset=chapter]{biblatex}
\usepackage{nameref}

\newcounter{segmentendfront}
\newcounter{segmentendmain}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\refname}%
  \section*{\refname\ for
    \ifnumgreater{\therefsegment}{\value{segmentendfront}}{%
      \ifnumgreater{\therefsegment}{\value{segmentendmain}}{%
        the
      }{%
        Chapter~\ref{refsegment:\therefsection\therefsegment} --
      }%
    }{%
      the
    }%
    \nameref{refsegment:\therefsection\therefsegment}%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\boolfalse{@mainmatter}% instead of \frontmatter, which would also switch
    %to Roman page numbering

\chapter{Introduction}

\cite{A01}

\mainmatter
\setcounter{segmentendfront}{\therefsection\therefsegment}

\chapter{First chapter}

\cite{A01,B02}

\chapter{Second chapter}

\cite{B02}

\backmatter
\setcounter{segmentendmain}{\therefsection\therefsegment}

\chapter{Conclusion}

\cite{C03}

\printbibheading
\bibbysegment[heading=bibintoc2]

\end{document}

enter image description here

1
  • While this does work, it kind of feels wrong to place the intro and conclusion in the frontmatter and backmatter respectively. Especially since there already is a frontmatter (toc,lof,lot,acknowledgements, preface) and a backmatter (bibliography, appendices, glossaries), that I'd like to separate from the main text of the thesis. Thanks for the help though!
    – Kpantzas
    Commented Aug 30, 2012 at 12:46
5

I think you can do this:

\chapter*{Introduction}
\begin{refsegment}
\cite{A01}
\end{refsegment}

Edit: The problem with the refsegment for the conclusion is not that there is a second refsegment but that with the option refsegment=chapter a \chapter command inserts a \begin{refsegment} (or something analog) and this isn't closed by the `\chapter*.

You could stop this segment before the conclusion:

\endrefsegment

\chapter*{Conclusion}

(A better solution would be to patch \chapter* too).

3
  • Doesn't seem to work.
    – lockstep
    Commented Aug 29, 2012 at 16:56
  • Yep, I tried that too, the nested refsection becomes a nested refsegment error
    – Kpantzas
    Commented Aug 29, 2012 at 16:59
  • Sorry I had used the wrong code for testing and so overlooked the conclusion problem. I have edited the answer. Commented Aug 29, 2012 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .