[Tex/LaTex] Override implicit resetnumbers when using Biblatex’s prefixnumbers

biblatex

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?

Best Answer

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

Related Question