TeX - LaTeX Asked on March 22, 2021
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
defblx@citation@entry#1#2{%
blx@bibreq{#1}%
ifinlist{#1}blx@cites
{}
{listgadd{blx@cites}{#1}}%
blx@auxwrite@mainaux{}{stringabx@aux@cite{#1}}%
ifinlistcs{#1}{blx@segm@thec@refsection @thec@refsegment}
{}
{listcsgadd{blx@segm@thec@refsection @thec@refsegment}{#1}}%
blx@auxwrite@mainaux{}{stringabx@aux@segm{thec@refsection}%
{thec@refsegment}%
{detokenize{#1}}}%
ifcsundef{blx@entry@refsegment@thec@refsection @#1}
{csnumgdef{blx@entry@refsegment@thec@refsection @#1}{thec@refsegment}}
{}%
blx@ifdata{#1}
{}
{ifcsdef{blx@miss@thec@refsection}
{ifinlistcs{#1}{blx@miss@thec@refsection}
{}
{blx@logreq@active{#2{#1}}}}
{blx@logreq@active{#2{#1}}}}}
defbibcheck{onlynew}{%
ifnumless{0csuse{blx@entry@refsegment@thec@refsection @thefield{entrykey}}}{thec@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 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.
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 onlyIf 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
defblx@citation@entry#1#2{%
blx@bibreq{#1}%
ifinlist{#1}blx@cites
{}
{listgadd{blx@cites}{#1}%
blx@auxwrite@mainaux{}{stringabx@aux@cite{#1}}}%
ifinlistcs{#1}{blx@segm@thec@refsection @thec@refsegment}
{}
{listcsgadd{blx@segm@thec@refsection @thec@refsegment}{#1}}%
blx@auxwrite@mainaux{}{%
stringabx@aux@segm{thec@refsection}{thec@refsegment}{detokenize{#1}}}%
ifcsundef{blx@entry@refsegment@thec@refsection @#1}
{csnumgdef{blx@entry@refsegment@thec@refsection @#1}{thec@refsegment}}
{}%
blx@ifdata{#1}
{}
{ifcsdef{blx@miss@thec@refsection}
{ifinlistcs{#1}{blx@miss@thec@refsection}
{}
{blx@logreq@active{#2{#1}}}}
{blx@logreq@active{#2{#1}}}}}
defbibcheck{onlynew}{%
ifnumless{0csuse{blx@entry@refsegment@thec@refsection @thefield{entrykey}}}
{thec@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}
Answered by moewe on March 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP