3

I would like to produce multiple bibliographies in a CV, separating papers that have no dates from those with dates (one way to tell if they are 'under review' or 'published' - I realise there are other ways to do this, such as keywords etc.). The same for conference papers.

With the changes to biblatex, my old code no longer works. I managed to make some progress using the solution here, ie, I do have separate bibliographies for journals papers and conferences with descending numbering, if I don't filter the empty-date entries.

I am filtering the entries produced by \printbibligraphy using 'check', which works, but is not compatible with the counters used for the descending numbering (ie, it does not exclude the 'filtered' papers).

How do I go about modifying the code below to fix the counters?

Thank you in advance!

\documentclass[10pt, a4paper]{article}
\usepackage[czech,english]{babel}  
\usepackage[backend=biber,style=ieee,defernumbers=true,sorting=keysort]{biblatex}


%%%%%%%%%%%%
% From https://tex.stackexchange.com/questions/367163/separate-biblatex-bibliographies-with-newest-entry-and-highest-reference-number:
% does not work correctly due to 'check' in bibliographies...

% 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}

%%%%%%%%%%%%
\DeclareSortingScheme{keysort}{
\sort[direction=descending]{\field{entrykey}  }
}

\addbibresource{pubs1.bib}
\addbibresource{pubs2.bib}

\begin{document}

\defbibcheck{confnoyear}{ \ifentrytype{inproceedings} {\iffieldundef{year}{}{\skipentry}} {\skipentry} }
\defbibcheck{journoyear}{ \ifentrytype{article}       {\iffieldundef{year}{}{\skipentry}} {\skipentry} }
\defbibcheck{confwyear}{  \ifentrytype{inproceedings} {\iffieldundef{year}{\skipentry}{}} {\skipentry} }
\defbibcheck{jourwyear}{  \ifentrytype{article}       {\iffieldundef{year}{\skipentry}{}} {\skipentry} }

% Journal papers under review (w/out years)
\newrefcontext[labelprefix=JS,sorting=keysort]
\printbibliography[check=journoyear]   \nocite{*}

% Journals published
\newrefcontext[labelprefix=J,sorting=keysort]
\printbibliography[check=jourwyear] \nocite{*}

% Conf papers under review (w/out years)
\newrefcontext[labelprefix=CS,sorting=keysort]
\printbibliography[check=confnoyear] \nocite{*}

% Conf papers published 
\newrefcontext[labelprefix=C,sorting=keysort]
\printbibliography[check=confwyear] \nocite{*}


\end{document}
moewe
  • 175,683

1 Answers1

4

This answer was written in 2018 and may no longer work as intended on newer systems. Refer to Reverse numbering in biblatex with customized bibchecks for an answer that works with biblatex v3.16 (2020-12-31).

The answer to Separate Biblatex bibliographies with newest entry and highest reference number at the top and Audrey's answer to Multibib reverse label or sort order, from which it derives, count the numbers of items in each refsection and then calculate the backwards label number from that. As you rightfully point out, your bibchecks skip over several entries that are still part of the refsection, so this approach leads to discontinuous numbering.

Here is a completely different approach. A solution for you set-up must be based on the specific bibliography environment since we need to count the maximum number of items in each bibliography environment to be able to count backwards in each bibliography.

For each bibliography environment we count the number of items in the list and write it to the .aux file so it is available at the beginning of the list in the next run. Then if the number of items is available at the beginning of the list, we recalculate the labelnumber based on the maximum number of items in the current bibliography. Finally that new labelnumber must be registered as the official labelnumber of the current item.

\documentclass[10pt, a4paper]{article}
\usepackage[czech,english]{babel}  
\usepackage[backend=biber,style=ieee,defernumbers=true,sorting=keysort]{biblatex}

\makeatletter \newcounter{bibenvcounter} \newcounter{bibitemcounter}[bibenvcounter]

\newcommand*{\auxkacz@envmax}[2]{% \csgdef{blxkacz@envmax@#1}{#2}}

\defbibenvironment{bibliography} {\stepcounter{bibenvcounter}% \list {\ifcsundef{blxkacz@envmax@\the\value{bibenvcounter}} {} {\numdef\abx@field@localnumber{% \csuse{blxkacz@envmax@\the\value{bibenvcounter}}% -\value{bibitemcounter}}% \csundef{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}% \blx@thelabelnumber}% \stepcounter{bibitemcounter}% \printtext[labelnumberwidth]{% \printfield{labelprefix}% \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 \blx@auxwrite@mainaux{}{% \string\auxkacz@envmax {\the\value{bibenvcounter}} {\the\value{bibitemcounter}}}} {\item} \makeatother

\defbibcheck{confnoyear}{ \ifentrytype{inproceedings} {\iffieldundef{year}{}{\skipentry}} {\skipentry} } \defbibcheck{journoyear}{ \ifentrytype{article} {\iffieldundef{year}{}{\skipentry}} {\skipentry} } \defbibcheck{confwyear}{ \ifentrytype{inproceedings} {\iffieldundef{year}{\skipentry}{}} {\skipentry} } \defbibcheck{jourwyear}{ \ifentrytype{article} {\iffieldundef{year}{\skipentry}{}} {\skipentry} }

\DeclareSortingScheme{keysort}{ \sort[direction=descending]{\field{entrykey}} }

\usepackage{filecontents} \begin{filecontents}{\jobname.bib} @inproceedings{a, author = {Author, A.}, title = {A Title}, date = {1980}, } @inproceedings{b, author = {Buthor, B.}, title = {B Title}, date = {1980}, } @inproceedings{c, author = {Buthor, C.}, title = {C Title}, date = {1980}, } @inproceedings{d, author = {Duthor, D.}, title = {A Title}, } @inproceedings{e, author = {Euthor, E.}, title = {B Title}, } \end{filecontents}

\addbibresource{\jobname.bib}

\begin{document} \newrefcontext[labelprefix=CS,sorting=keysort] \printbibliography[check=confnoyear] \nocite{*}

\newrefcontext[labelprefix=C,sorting=keysort] \printbibliography[check=confwyear] \nocite{*} \end{document}

Bibliography 1 shows "[CS2] E. Euthor, “B title”.//[CS1] D. Duthor, “A title”." Bibliography 2 has "[C3] C. Buthor, “C title”, 1980.//[C2] B. Buthor, “B title”, 1980.//[C1] A. Author, “A title”, 1980."

moewe
  • 175,683
  • I'm running the code but I get no references. What could be the reason? Do I need to have a separate bib file? – Bob Dec 24 '19 at 06:35
  • @Bob I just ran the code from the answer and got exactly the same output as shown in the picture. There are several things that could have gone wrong at your end. Can you run a simple document using biblatex and Biber? (Try https://gist.github.com/moewew/6e738db2c03f1e1a2653e33d3101b524 and do not modify anything in that file). Do you get any warnings or errors in the .log or .blg files? – moewe Dec 24 '19 at 06:56
  • when I'm running the suggested file, I get a page with "sigfridsson" – Bob Dec 24 '19 at 07:00
  • @Bob Did you run Biber on your file? You need to compile it with LaTeX, Biber, LaTeX, LaTeX (https://tex.stackexchange.com/q/63852/35864). See https://tex.stackexchange.com/q/154751/35864 for help on getting your editor to run Biber instead of BibTeX for you. – moewe Dec 24 '19 at 07:01
  • I ran using Biber based on tex.stackexchange.com/q/154751/35864 but still, I only get "sigfridsson" – Bob Dec 24 '19 at 07:14
  • @Bob Delete all auxiliary files, then run LaTeX, Biber, LaTeX, LaTeX in that order. If you still don't get any output, please show me the .log and .blg files. Upload them to a text-sharing website such as pastebin or GitHub Gists. – moewe Dec 24 '19 at 07:16
  • The order LaTeX, Biber, LaTeX, LaTeX is not clear to me. In TeXstudio, for bibliography tool, I only have Biber, BibTex, and BibTex 8bit, – Bob Dec 24 '19 at 07:19
  • @Bob LaTeX is not a bibliography tool, so you won't find it in there. It is just the normal engine you use to compile your LaTeX document. You can probably run it by clicking the green arrow. – moewe Dec 24 '19 at 07:21
  • I put the file here: https://gist.github.com/wereHamster/772010/e199a581c403687158838245ba3892a556745b79?signup=true#gistcomment-3119726 – Bob Dec 24 '19 at 07:47
  • @Bob That looks good. According to the .blg Biber finds the entry and LaTeX finds the .bbl file, so you should see the expected output: "Sigfridsson and Ryde 1998". – moewe Dec 24 '19 at 07:50
  • but I can even see the pdf now. – Bob Dec 24 '19 at 07:53
  • I had to change \abx@field@localnumber to \abx@field@labelnumber. With localnumber, the entries are listed as CS2, CS4, C2, C4, C6. With labelnumber the result is as in the screenshot. – Keelan Apr 07 '23 at 11:55