You could try the following.
We will presume we have two .bib
files: \jobname-1.bib
and \jobname-2.bib
, here created via filecontents*
\begin{filecontents*}{\jobname-1.bib}
@inproceedings{slam2001,
author = {Thomas Ball and Sriram K. Rajamani},
title = {Automatically Validating Temporal Safety Properties of Interfaces},
booktitle = {Proceedings of the 8th International SPIN Workshop on Model Checking of Software},
editor = {Matthew Dwyer},
date = {2001},
}
\end{filecontents*}
\begin{filecontents*}{\jobname-2.bib}
@article{blast2007,
author = {Dirk Beyer and Thomas A. Henzinger and Ranjit Jhala and Rupak Majumdar},
title = {The software model checker {BLAST}},
subtitle = {Applications to software engineering},
journal = {International Journal on Software Tools for Technology Transfer},
date = {2007},
volume = {9},
}
\end{filecontents*}
\addbibresource{\jobname-1.bib}
\addbibresource{\jobname-2.bib}
These two files will be added to different keywords with Biber's sourcemapping
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-1.bib}
\step[fieldset=keywords, fieldvalue={, primary}, append]
}
\map{
\perdatasource{\jobname-2.bib}
\step[fieldset=keywords, fieldvalue={, secondary}, append]
}
}
}
\jobname-1.bib
gets the keyword
primary
, \jobname-2.bib
gets secondary
. (I chose primary
and secondary
here, but you can pick anything you like. Just make sure that these keywords are not used for anything else in your .bib
file or in your bibliography setup.) Note that the names of the .bib
files are 'hard-coded' in \perdatasource
. If you have different files names, you need to adapt the code accordingly.
If you insist on continuous numbering (i.e. do not want the second bibliography to start at [B1]) we'll need to put an end to biblatex
's auto-detection of resetnumbers
in case labelprefix
is used:
\makeatletter
\providerobustcmd*{\blx@kv@defkey}{\define@key}
\blx@kv@defkey{blx@bib1}{noresetnumbersforlabelprefix}[true]{%
\ifstrequal{#1}{true}
{\let\blx@saved@refcontext@labelprefix\blx@refcontext@labelprefix
\let\blx@saved@refcontext@labelprefix\blx@refcontext@labelprefix@real
\let\blx@refcontext@labelprefix\@empty
\let\blx@refcontext@labelprefix@real\@empty}
{}}
\blx@kv@defkey{blx@bib2}{noresetnumbersforlabelprefix}[true]{%
\ifstrequal{#1}{true}
{\let\blx@refcontext@labelprefix\blx@saved@refcontext@labelprefix
\let\blx@refcontext@labelprefix@real\blx@saved@refcontext@labelprefix}
{}}
\makeatother
All the entries can be cited via \cite
(so the keyword
does not matter, there is not \citeA
or \citeB
).
The bibliography is printed with
\newrefcontext[labelprefix=A]
\printbibliography[keyword=primary, noresetnumbersforlabelprefix, title=Primary]
\newrefcontext[labelprefix=B]
\printbibliography[keyword=secondary, noresetnumbersforlabelprefix, title=Secondary]
That is the first bibliography only contains entries with the keyword
primary
(effectively that is entries from \joabname-1.bib
), while the second contains secondary
entries (\jobname-2.bib
). I have added prefixes to the labels via the labelprefix
option of \newrefcontext
(that comes closer to your example).
The heading/title is controlled by the title
option.
MWE
\documentclass{article}
\usepackage[style=numeric, defernumbers=true, backend=biber, maxnames=999]{biblatex}
\usepackage{hyperref}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-1.bib}
\step[fieldset=keywords, fieldvalue={, primary}, append]
}
\map{
\perdatasource{\jobname-2.bib}
\step[fieldset=keywords, fieldvalue={, secondary}, append]
}
}
}
\makeatletter
\providerobustcmd*{\blx@kv@defkey}{\define@key}
\blx@kv@defkey{blx@bib1}{noresetnumbersforlabelprefix}[true]{%
\ifstrequal{#1}{true}
{\let\blx@saved@refcontext@labelprefix\blx@refcontext@labelprefix
\let\blx@saved@refcontext@labelprefix\blx@refcontext@labelprefix@real
\let\blx@refcontext@labelprefix\@empty
\let\blx@refcontext@labelprefix@real\@empty}
{}}
\blx@kv@defkey{blx@bib2}{noresetnumbersforlabelprefix}[true]{%
\ifstrequal{#1}{true}
{\let\blx@refcontext@labelprefix\blx@saved@refcontext@labelprefix
\let\blx@refcontext@labelprefix@real\blx@saved@refcontext@labelprefix}
{}}
\makeatother
\begin{filecontents*}{\jobname-1.bib}
@inproceedings{slam2001,
author = {Thomas Ball and Sriram K. Rajamani},
title = {Automatically Validating Temporal Safety Properties of Interfaces},
booktitle = {Proceedings of the 8th International SPIN Workshop on Model Checking of Software},
editor = {Matthew Dwyer},
date = {2001},
}
@article{blast2008,
author = {Dirk Beyer and Thomas A. Henzinger and Ranjit Jhala and Rupak Majumdar},
title = {BLAST II},
journal = {International Journal on Software Tools for Technology Transfer},
date = {2008},
volume = {18},
}
\end{filecontents*}
\begin{filecontents*}{\jobname-2.bib}
@article{blast2007,
author = {Dirk Beyer and Thomas A. Henzinger and Ranjit Jhala and Rupak Majumdar},
title = {The software model checker {BLAST}},
subtitle = {Applications to software engineering},
journal = {International Journal on Software Tools for Technology Transfer},
date = {2007},
volume = {9},
}
@inproceedings{slam2002,
author = {Thomas Ball and Sriram K. Rajamani},
title = {Interfaces are Cool!},
booktitle = {Proceedings of the 8th International SPIN Workshop on Model Checking of Software},
date = {2002},
}
\end{filecontents*}
\addbibresource{\jobname-1.bib}
\addbibresource{\jobname-2.bib}
\begin{document}
CiteA~\cite{slam2001,slam2002}, CiteB~\cite{blast2007,blast2008}
\newrefcontext[labelprefix=A]
\printbibliography[keyword=primary, noresetnumbersforlabelprefix, title=Primary]
\newrefcontext[labelprefix=B]
\printbibliography[keyword=secondary, noresetnumbersforlabelprefix, title=Secondary]
\end{document}
Hyperlinking seemed to work rather well here.
edit The answer was updated to work with more recent versions of biblatex
(tested with v3.14, but it should work from v3.12 onward). If you are using an ancient version of biblatex
(v3.3 or below), please refer to the edit history.