Since we want to sort entries with a certain property before other entries and sorting is done by Biber we will have to tell Biber in the .bib
which entry has this property (there is a way to get out of this limitation, see below for more details).
So we cannot use bibcategories any more, we will use keywords
instead.
Just add keywords = {own}
to the relevant entries
@book{a,
author = "I",
year = "1973",
keywords = {own},
}
Naturally the bibliographies are filtered with keyword
and notkeyword
now
\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]
We then check for own
and, if the keyword is present, fill the presort
field with A
, otherwise it gets a B
.
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=keywords, match=\regexp{(^|,)own(,|$)}, final]
\step[fieldset=presort, fieldvalue = {A}]
}
\map{
\step[fieldset=presort, fieldvalue = {B}]
}
}
}
MWE
\documentclass{article}
\usepackage[
sorting = ynt,
bibstyle = numeric,
defernumbers = true,
sortcites = true
]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{a,
author = "I",
year = "1973",
keywords = {own},
}
@book{a2,
author = "I",
year = "1923",
keywords = {own},
}
@book{b,
author = "You",
year = "1959",
}
@book{c,
author = "You",
year = "1970",
keywords = {notmine},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=keywords, match=\regexp{(^|,)own(,|$)}, final]
\step[fieldset=presort, fieldvalue = {A}]
}
\map{
\step[fieldset=presort, fieldvalue = {B}]
}
}
}
\begin{document}
\cite{a,a2,b,c}
\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]
\end{document}

To do everything from within your .tex
file use
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
\step[fieldset=presort, fieldvalue = {A}]
}
\map[overwrite=true]{
\step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
\step[fieldset=keywords, fieldvalue = {own}, append]
}
\map{
\step[fieldset=presort, fieldvalue = {B}]
}
}
}
Where you replace (a|a2)
in the two steps above with a list of "own" entry keys separated by |
.
MWE
\documentclass{article}
\usepackage[
sorting = ynt,
bibstyle = numeric,
defernumbers = true,
sortcites = true
]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{a,
author = "I",
year = "1973",
}
@book{a2,
author = "I",
year = "1923",
}
@book{b,
author = "You",
year = "1959",
}
@book{c,
author = "You",
year = "1970",
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
\step[fieldset=presort, fieldvalue = {A}]
}
\map[overwrite=true]{
\step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
\step[fieldset=keywords, fieldvalue = {own}, append]
}
\map{
\step[fieldset=presort, fieldvalue = {B}]
}
}
}
\begin{document}
\cite{a,a2,b,c}
\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]
\end{document}