7

I have to use multiple bibliographies, but some of those should share the same number prefix. Biblatex allows to set prefixnumbers, but this implicitly enforces resetnumbers. This results in multiple usage of a label, since the numbering is resetted at each printbibliography call. The following example illustrates the problem:

\documentclass[a4paper,oneside]{article}

\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
  @Misc{A,
    author       = {A Author},
    title        = {Title},
    year         = 2013,
  }

  @Misc{B,
    author       = {B Buthor},
    title        = {Title},
    year         = 2013,
  }

  @Misc{C,
    author       = {C Cuthor},
    title        = {Title},
    year         = 2013,
  }
\end{filecontents*}

\usepackage[english]{babel}
\usepackage[style=numeric-comp,defernumbers,backend=biber]{biblatex}
\addbibresource{bib.bib}

\DeclareBibliographyCategory{catA1}
\DeclareBibliographyCategory{catA2}
\DeclareBibliographyCategory{catB}
\addtocategory{catA1}{A}
\addtocategory{catA2}{B}
\addtocategory{catB}{C}

\begin{document}
  \cite{A} supposed to be [A1]\\
  \cite{B} supposed to be [A2]\\
  \cite{C} supposed to be [B1]

  \section{Part A1}
  \printbibliography[category=catA1,prefixnumbers={A}]

  \section{Part A2}
  \printbibliography[category=catA2,prefixnumbers={A}]%resetnumbers=false does not work here

  \section{Part B}
  \printbibliography[category=catB,prefixnumbers={B}]
\end{document}

How can I tell Biblatex to NOT reset the numbering when printing the second bibliography?

3 Answers 3

4

A possible, and "hackish", way to do this is to use the biblatex ability to (re)define different bibliography environments.

Thus one can create two bibliography environments: one for the A prefix publications, and the second for the B publications (the solution use enumitem package, i.e., \usepackage{enumitem}, to help with the redefinition of the bibliography environments as enumerate, and its ability to resume numeration over different enumerates)

\defbibenvironment{bibliography}
  {\begin{enumerate}[series=bib,resume=bib,label=A\arabic*.,ref=A\arabic*]}
  {\end{enumerate}}
  {\item\label{\thefield{entrykey}}}

\defbibenvironment{bbiblio}
  {\begin{enumerate}[label=B\arabic*.,ref=B\arabic*]}
  {\end{enumerate}}
  {\item\label{\thefield{entrykey}}}

Notice that we have to define how the label of the enumerate appears and also the format of the references (ref). This solution also requires to redefine the various citation commands. For \cite a possible redefinition is

\DeclareCiteCommand{\cite}
  [\mkbibbrackets]
  {}
  {\ref{\thefield{entrykey}}}
  {\addcomma\addspace}
  {\iffieldundef{postnote}{}{\addcomma\addspace\printfield{postnote}}}

Similar definitions are needed for other cite commands. A better way would be to redefine the appropriate bibmacros.

The final step is to call the bibliography with the desired bibliography environment using the env option (this it not required for bibliography).

\section{Part A1}
\printbibliography[category=catA1]

\section{Part A2}
\printbibliography[category=catA2]

\section{Part B}
\printbibliography[category=catB,env=bbiblio]

The result is

enter image description here

1
  • Thank you! Of course I would prefer Biblatex to keep track of a per-prefix-numbering automatically, but this gets the job done.
    – Jeorsch
    Nov 18, 2013 at 15:12
3

The accepted answer breaks several things, e.g., the conversion of consecutive numbers into ranges for the numeric-comp style. Since version 2.9a of biblatex, the option resetnumbers accepts a number. This allows a less hackish solution using a counter for each part:

\newcounter{BibA}
\setcounter{BibA}{1}
\newcounter{BibB}
\setcounter{BibB}{1}

The number of entries in a bibliography can be obtained using the following hooks:

\newcounter{NumberOfBibEntries}
\AtBeginBibliography{\setcounter{NumberOfBibEntries}{0}}
\AtEveryBibitem{\stepcounter{NumberOfBibEntries}}

The part counters can then be updated after each invocation of \printbibliography and used as an argument to resetnumbers in the following bibliographies:

\section{Part A1}
\printbibliography[category=catA1,prefixnumbers={A}]
\addtocounter{BibA}{\value{NumberOfBibEntries}}

\section{Part A2}
\printbibliography[category=catA2,prefixnumbers={A}, resetnumbers=\number\value{BibA}]
\addtocounter{BibA}{\value{NumberOfBibEntries}}

\section{Part B}
\printbibliography[category=catB,prefixnumbers={B}]
\addtocounter{BibB}{\value{NumberOfBibEntries}}

It is probably best to wrap this in a macro like

\newcommand{\myprintbibliography}[2][]{%
    \printbibliography[#1 ,prefixnumbers={#2}, resetnumbers=\number\value{Bib#2}]%
    \addtocounter{Bib#2}{\value{NumberOfBibEntries}}%
}

This full document:

\documentclass[a4paper,oneside]{article}

\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
    @Misc{A,
        author       = {A Author},
        title        = {Title},
        year         = 2013,
    }

    @Misc{B,
        author       = {B Buthor},
        title        = {Title},
        year         = 2013,
    }

    @Misc{C,
        author       = {C Cuthor},
        title        = {Title},
        year         = 2013,
    }

    @Misc{D,
        author       = {D Duthor},
        title        = {Title},
        year         = 2013,
    }

\end{filecontents*}

\usepackage[english]{babel}
\usepackage{enumitem}
\usepackage[style=numeric-comp,defernumbers,backend=biber]{biblatex}
\addbibresource{bib.bib}

\DeclareBibliographyCategory{catA1}
\DeclareBibliographyCategory{catA2}
\DeclareBibliographyCategory{catB}
\addtocategory{catA1}{A,B}
\addtocategory{catA2}{C}
\addtocategory{catB}{D}

\newcounter{NumberOfBibEntries}
\AtBeginBibliography{\setcounter{NumberOfBibEntries}{0}}
\AtEveryBibitem{\stepcounter{NumberOfBibEntries}}

\newcounter{BibA}
\setcounter{BibA}{1}
\newcounter{BibB}
\setcounter{BibB}{1}

\newcommand{\myprintbibliography}[2][]{%
    \printbibliography[#1 ,prefixnumbers={#2}, resetnumbers=\number\value{Bib#2}]
    \addtocounter{Bib#2}{\value{NumberOfBibEntries}}    
}

\parindent=0pt
\begin{document}
    \cite{A, B, C} supposed to be [A1-A3]\\
    \cite{D} supposed to be [B1]\\

    \section{Part A1}
    \myprintbibliography[category=catA1]{A}

    \section{Part A2}
    \myprintbibliography[category=catA2]{A}

    \section{Part B}
    \myprintbibliography[category=catB]{B}

\end{document}

The only problem I encountered is related to the necessary defernumbers option. As the manual states, sometimes the .aux file has to be deleted to obtain the correct numbering.

1

With biblatex 3.5+biber 2.6 (both currently in DEV on Sourceforge), this behaviour is finally fixed. It is now possible to override the implicit resetnumbers in the normal way (example updated for changes to prefixnumbers which moved into the refcontext mechanism with a name change to labelprefix in biblatex 3.3):

\section{Part A1}
\newrefcontext[labelprefix=A]
\printbibliography[category=catA1]

\section{Part A2}
\printbibliography[category=catA2, resetnumbers=false]

\section{Part B}
\newrefcontext[labelprefix=B]
\printbibliography[category=catB]

You must log in to answer this question.

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