0

A solution for continuous numbering across sub-bibliograhies without duplication and with support for nocite was previously given. However, simply adding sorting=none to the biblatex package declaration causes all references to be assigned the number zero.

The following MWE is identical to the second one in the linked post, save for the addition of sorting=none:

\documentclass{article}
\usepackage[sorting=none,defernumbers=true]{biblatex}

\makeatletter
\def\blx@citation@entry#1#2{%
  \blx@bibreq{#1}%
  \ifinlist{#1}\blx@cites
    {}
    {\listgadd{\blx@cites}{#1}}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@cite{#1}}%
  \ifinlistcs{#1}{blx@segm@\the\c@refsection @\the\c@refsegment}
    {}
    {\listcsgadd{blx@segm@\the\c@refsection @\the\c@refsegment}{#1}}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@segm{\the\c@refsection}%
                                               {\the\c@refsegment}%
                                               {\detokenize{#1}}}%
  \ifcsundef{blx@entry@refsegment@\the\c@refsection @#1}
    {\csnumgdef{blx@entry@refsegment@\the\c@refsection @#1}{\the\c@refsegment}}
    {}%
  \blx@ifdata{#1}
    {}
    {\ifcsdef{blx@miss@\the\c@refsection}
       {\ifinlistcs{#1}{blx@miss@\the\c@refsection}
          {}
          {\blx@logreq@active{#2{#1}}}}
       {\blx@logreq@active{#2{#1}}}}}

\defbibcheck{onlynew}{%
  \ifnumless{0\csuse{blx@entry@refsegment@\the\c@refsection @\thefield{entrykey}}}{\the\c@refsegment}
    {\skipentry}
    {}}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
\newrefsegment
refsegment \therefsegment:
\cite{sigfridsson,worman}
\printbibliography[segment=\therefsegment,check=onlynew]

\newrefsegment
refsegment \therefsegment:
\cite{sigfridsson,geer,nussbaum}\nocite{knuth:ct:a}
\printbibliography[segment=\therefsegment,check=onlynew]

\newrefsegment
refsegment \therefsegment:
\cite{sigfridsson,geer,pines,worman}\nocite{knuth:ct:a,knuth:ct:b}
\printbibliography[segment=\therefsegment,check=onlynew]
\end{document}

The document was compiled as follows:

$ pdflatex mwe.tex
$ biber mwe
$ pdflatex mwe.tex
$ pdflatex mwe.tex

However, no matter how many times pdflatex or biber are run, the following warning is always emitted:

LaTeX Warning: There were undefined references.


Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                mwe
(biblatex)                and rerun LaTeX afterwards.

The output is as follows: enter image description here

The output of the blg file is as follows:

[0] Config.pm:304> INFO - This is Biber 2.12
[0] Config.pm:307> INFO - Logfile is 'mwe.blg'
[37] biber:315> INFO - === Sun Nov 24, 2019, 23:06:15
[62] Biber.pm:371> INFO - Reading 'mwe.bcf'
[151] Biber.pm:889> INFO - Found 7 citekeys in bib section 0
[169] Biber.pm:4093> INFO - Processing section 0
[182] Biber.pm:4254> INFO - Looking for bibtex format file 'biblatex-examples.bib' for section 0
[277] bibtex.pm:1512> INFO - LaTeX decoding ...
[560] bibtex.pm:1329> INFO - Found BibTeX data source '/usr/share/texlive/texmf-dist/bibtex/bib/biblatex/biblatex/biblatex-examples.bib'
[634] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'normalization = NFD' with 'normalization = prenormalized'
[634] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'variable = shifted' with 'variable = non-ignorable'
[634] Biber.pm:3921> INFO - Sorting list 'none/global//global/global' of type 'entry' with template 'none' and locale 'en-US'
[635] Biber.pm:3927> INFO - No sort tailoring available for locale 'en-US'
[640] bbl.pm:636> INFO - Writing 'mwe.bbl' with encoding 'UTF-8'
[644] bbl.pm:739> INFO - Output to mwe.bbl

The output of the log file is included here.

user001
  • 7,964
  • 1
    The MWE works for me exactly as posted when run with LaTeX, Biber, LaTeX, LaTeX. The only real difference so far is that I am running a current biblatex v3.13/Biber 2.13 combo an not 3.12 and 2.12. Any chance you could do an update? – moewe Nov 25 '19 at 07:36
  • Not that I have high hopes that there is an easy way to resolve this issue without updating. But can you check the contents of mwe.bbl. Does it look roughly like https://gist.github.com/moewew/f871d0182ad732d3e065694c3643321f? – moewe Nov 25 '19 at 07:54
  • @moewe: I believe I would have to backport the newer version. I will see if I can try it on a newer machine, but won't have access until tomorrow. – user001 Nov 25 '19 at 07:54
  • The easiest way to get a fully up-to-date TeX system on Linux is a vanilla TeX live from TUG: https://tex.stackexchange.com/q/1092/35864. (You can have a look at the changes between 3.12 and 3.13 here, and that are only the biblatex changes that one might be able to replicate, if this was an error in Biber there is usually no way to fix this without updating). – moewe Nov 25 '19 at 07:55
  • @moewe: Regarding the bbl, they are identical apart from the biblatex version line (biblatex bbl format version 3.0 vs. biblatex bbl format version 3.1). Regarding upgrading, I will have a look at that post, though I normally prefer to stick with the versions available in the repository (which for texlive is 2018.20190227-2) for maintenance/stability reasons. Regardless, the problem reported in this post is most likely a version issue as you've pointed out. Thanks. – user001 Nov 25 '19 at 08:02
  • If the .bbl is similar enough, chances are this is a biblatex issue. In that case it might be possible to inject some code into the document preamble to fix the issue without updating. But the changes between 3.12 and 3.13 are not insignificant (the most interesting file biblatex.sty has seen about 1600 changes). If you are lucky, someone may go through all of the changes and try to figure out what needs to be done, but that is quite time consuming. ... – moewe Nov 25 '19 at 08:06
  • ... Given that there is a simple solution (get an up to date vanilla TeX live) that is safe (you can install it in a way not to interfere with your currently installed TeX live if you want and only activate it via PATH settings), I don't think this is an urgent issue and I'm afraid I'm going to be quite busy this week and next week, so I can't promise anything. – moewe Nov 25 '19 at 08:08
  • @moewe: Agreed. Please don't waste time looking into this. I will either install a second texlive alongside my system's texlive or compile on a newer machine. Thanks again for your help. – user001 Nov 25 '19 at 08:10
  • FWIW: I found that it may have to do with the BibTeX entry types. I used inproceedings, unpublished, and article it assigned number while when I assigned other types (https://www.bibtex.com/e/entry-types/#techreport) it threw all zeros. No idea why. – Rajesh Feb 06 '21 at 21:47
  • Consider accepting the provided answer. – Dr. Manuel Kuehner Feb 11 '21 at 07:41

1 Answers1

1

The code from biblatex: continuous reference numbering without duplication was written for biblatex v3.13.

Hence, the MWE works fine as posted with biblatex v3.13 or above.

If at all possible, update your TeX system to a current version.

There were some changes to the internal macro \blx@citation@entry that we patch here between v3.12 and v3.13, so it is not completely unexpected that the code does not work for older biblatex versions.


biblatex v3.12 only

If you are stuck with biblatex v3.12 and absolutely cannot update, you need the following code based on the v3.12 version of \blx@citation@entry

\documentclass{article}
\usepackage[sorting=none,defernumbers=true]{biblatex}

\makeatletter \def\blx@citation@entry#1#2{% \blx@bibreq{#1}% \ifinlist{#1}\blx@cites {} {\listgadd{\blx@cites}{#1}% \blx@auxwrite@mainaux{}{\string\abx@aux@cite{#1}}}% \ifinlistcs{#1}{blx@segm@\the\c@refsection @\the\c@refsegment} {} {\listcsgadd{blx@segm@\the\c@refsection @\the\c@refsegment}{#1}}% \blx@auxwrite@mainaux{}{% \string\abx@aux@segm{\the\c@refsection}{\the\c@refsegment}{\detokenize{#1}}}% \ifcsundef{blx@entry@refsegment@\the\c@refsection @#1} {\csnumgdef{blx@entry@refsegment@\the\c@refsection @#1}{\the\c@refsegment}} {}% \blx@ifdata{#1} {} {\ifcsdef{blx@miss@\the\c@refsection} {\ifinlistcs{#1}{blx@miss@\the\c@refsection} {} {\blx@logreq@active{#2{#1}}}} {\blx@logreq@active{#2{#1}}}}}

\defbibcheck{onlynew}{% \ifnumless{0\csuse{blx@entry@refsegment@\the\c@refsection @\thefield{entrykey}}} {\the\c@refsegment} {\skipentry} {}} \makeatother

\addbibresource{biblatex-examples.bib}

\begin{document} \newrefsegment refsegment \therefsegment: \cite{sigfridsson,worman} \printbibliography[segment=\therefsegment,check=onlynew]

\newrefsegment refsegment \therefsegment: \cite{sigfridsson,geer,nussbaum}\nocite{knuth:ct:a} \printbibliography[segment=\therefsegment,check=onlynew]

\newrefsegment refsegment \therefsegment: \cite{sigfridsson,geer,pines,worman}\nocite{knuth:ct:a,knuth:ct:b} \printbibliography[segment=\therefsegment,check=onlynew] \end{document}

Expected citations

moewe
  • 175,683