biblatex:所有参考文献均分配编号零,连续编号,无重复,排序=无

biblatex:所有参考文献均分配编号零,连续编号,无重复,排序=无

一种跨子书目连续编号且不重复的解决方案,并nocite支持先前给出。但是,简单地添加sorting=none到包声明中biblatex会导致所有引用都被分配数字零。

以下 MWE 与链接帖子中的第二个 MWE 相同,只是添加了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}

该文件内容如下:

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

但是,无论运行多少次pdflatexbiber总会发出以下警告:

LaTeX Warning: There were undefined references.


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

输出如下: 在此处输入图片描述

blg文件的输出如下:

[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

日志文件的输出包括这里

答案1

代码来自biblatex:连续参考编号,无重复是为biblatexv3.13 编写的。

因此,MWE 在biblatexv3.13 或更高版本中运行良好。

如果可能的话,将您的 TeX 系统更新至最新版本。

我们在 v3.12 和 v3.13 之间修补的内部宏有一些更改,因此代码不适用于旧版本\blx@citation@entry也就不足为奇了。biblatex


biblatex仅限 v3.12

如果你被困在biblatexv3.12 中,无法更新,你需要以下基于 v3.12 版本的代码\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}

预期引用

相关内容