3

I would like to have a similar biblatex behaviour as described here, i.e. separate bibliographies for different publication types, each bibliography should 1) be prefixed with a corresponding label (C for conference publications, J for journals etc), 2) sorted so that the newest entry is at the top (defined by the publication year) and 3) with reference numbers sorted in descending order per bibliography, i.e. the newest entry should have the highest number.

Journal articles
----------------
[J3]    reference from 2017
[J2]    reference from 2016
[J1]    reference from 2015

Conference publications
-----------------------
[C4]    reference from 2017
[C3]    reference from 2017
[C2]    reference from 2016
[C1]    reference from 2015

I currently have the following:

\usepackage[backend=biber,
        isbn=true,
        giveninits=true,
        style=numeric,
        maxnames=99,
        sorting=ydnt,
        defernumbers=true,
        autocite=superscript]{biblatex}

\subsection*{Journal articles}
\begin{refcontext}[labelprefix=J]
\printbibliography[type=article]
\end{refcontext}

\subsection*{Conference publications}
\begin{refcontext}[labelprefix=C]
\printbibliography[type=inproceedings]

Separate bibliographies works fine, labelprefix also works as desired, sorting by year in descending order as well. However, if I try the solution mentioned in the above question I get very high reference numbers (in the 500s).

Is the above behaviour possible at all and, if yes, what is the most elegant solution using current biblatex etc.?

Thanks a lot in advance!

1

This answer is based on Audrey's answer to Multibib reverse label or sort order.

Because some internals have changed over time, a few tweaks are necessary. In recent versions it could happen that certain entries would be processed multiple times, so we need to make sure each entry is processed only once.

This solution needs the defernumbers option.

\documentclass{article}
\usepackage[backend=biber,style=numeric,sorting=ydnt,defernumbers]{biblatex}

% Count total number of entries in each refsection
\AtDataInput{%
  \ifcsundef{bbx@processedentries:\therefsection}
    {\csgdef{bbx@processedentries:\therefsection}{}}
    {}%
  \xifinlistcs{\thefield{entrykey}}{bbx@processedentries:\therefsection}{}{%
    \listcsxadd{bbx@processedentries:\therefsection}{\thefield{entrykey}}%
    \csnumgdef{bbx@entrycount:\therefsection:\thefield{entrytype}}{%
      \csuse{bbx@entrycount:\therefsection:\thefield{entrytype}}+1}}}

% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}    
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{bbx@entrycount:\therefsection:\thefield{entrytype}}+1-#1\relax}

\addbibresource{biblatex-examples.bib}

\begin{document}
\nocite{aksin,bertram,chiu,companion,padhye,angenendt,moraux,sigfridsson}

\newrefcontext[labelprefix=J]
\printbibliography[type=article]

\newrefcontext[labelprefix=C]
\printbibliography[type=inproceedings]
\end{document}
  • Works like a charm - thank you very much! – andyknownasabu Apr 28 '17 at 11:31
0

Many thanks, moewe. Your code is excellent. I slightly modified it for the case of 'sorting by keywords'. For instance, I have several entry types at @misc (keywords: posters, presentations, maps, codes). Sorting by 'entrytypes' in this case does not work. But it does work when I changed 'entrytype' to 'keywords' in your code :

\AtDataInput{%
  \ifcsundef{bbx@processedentries:\therefsection}
    {\csgdef{bbx@processedentries:\therefsection}{}}
    {}%
  \xifinlistcs{\thefield{entrykey}}{bbx@processedentries:\therefsection}{}{%
    \listcsxadd{bbx@processedentries:\therefsection}{\thefield{entrykey}}%
    \csnumgdef{bbx@entrycount:\therefsection:\thefield{keywords}}{%
      \csuse{bbx@entrycount:\therefsection:\thefield{keywords}}+1}}}

% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}    
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{bbx@entrycount:\therefsection:\thefield{keywords}}+1-#1\relax}
  • Note that \thefield{keywords} only works reliably when the field contains a single keyword. Otherwise a more complex scolution would be needed. – moewe Dec 23 '18 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.