The answer of moewe to the question Biblatex: Two bibliographies with different styles and sortings is almost what I want to achieve. Because of the large number of entries in my document, I would prefer to use the style numeric-comp
instead of just numeric
. How can I get this?
Extended MWE:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author = {Author Aaa},
title = {Some Title},
publisher = {Some Publisher},
year = 2003,
}
@BOOK{BookB02,
author = {Author Bbb},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB09,
author = {Author Jjj},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB10,
author = {Author Kkk},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB11,
author = {Author Lll},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\begin{filecontents}{biblatextest2.bib}
@MISC{LinkC04,
author = {Author Ccc},
title = {Some Title},
year = 2004,
url = {www.test1.com/bild.jpg},
}
@MISC{LinkD01,
author = {Author Ddd},
title = {Some Title},
year = 2001,
url = {www.test2.com/bild.jpg},
}
@MISC{LinkD05,
author = {Author Eee},
title = {Some Title},
year = 2004,
url = {www.test3.com/bild.jpg},
}
@MISC{LinkD06,
author = {Author Fff},
title = {Some Title},
year = 2001,
url = {www.test4.com/bild.jpg},
}
@MISC{LinkD07,
author = {Author Ggg},
title = {Some Title},
year = 2004,
url = {www.test5.com/bild.jpg},
}
@MISC{LinkD08,
author = {Author Hhh},
title = {Some Title},
year = 2001,
url = {www.test6.com/bild.jpg},
}
\end{filecontents}
\usepackage[style = alphabetic, labelnumber, defernumbers = true, backend = biber]{biblatex}
\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary, append]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary, append]
}
}
}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifkeyword{secondary}
{\printfield{labelnumber}}
{\printfield{labelalpha}%
\printfield{extraalpha}}}}
\defbibenvironment{bibliographyNUM}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\assignrefcontextkeyws[sorting=none]{secondary}
\begin{document}
The first two citations \cite{LinkD07,LinkC04} and \cite{BookB10,BookB11,BookB02,BookB09}.
The others are \cite{LinkD08,LinkD01,LinkD05,LinkD06} and \cite{BookA03}.
\printbibliography[title=Bibliography, keyword=primary]
\newrefcontext[sorting=none]
\printbibliography[env=bibliographyNUM,title=References, keyword=secondary, resetnumbers]
\end{document}
Thank you for your help in advance.
alphabetic
style sorted by author name and the second one innumeric-comp
style sorted by citations order.numeric-comp
would be quite a bit more complicated, sincenumeric-comp
's cite macros are vastly more complicated thannumeric
's. What happens if you cite numeric and alphabetic citations in the same\cite
?alphabetic.cbx
,numeric.cbx
andnumeric-comp.cbx
. It seems to work well:The first two citations \cite{BookB10,LinkD07,LinkC04} and \cite{BookB10,BookB11,LinkD07,LinkC04,BookB02,BookB09}. The others are \cite{LinkD08,LinkD01,BookA03,LinkD05,LinkD06} and \cite{BookA03,LinkC04}.
Just replacingstyle=alphabetic
withbibstyle = alphabetic, citestyle = numeric
gives the same result. But withbibstyle = alphabetic, citestyle = numeric-comp
is the entire citation stylenumeric
.