Override implicit resetnumbers when using Biblatex's prefixnumbers
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 enumerate
s)
\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 bibmacro
s.
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
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.