Biblatex,当使用 nocite 和 defernumbers 调用未知键时,编号为零

Biblatex,当使用 nocite 和 defernumbers 调用未知键时,编号为零

在我的“真实”示例中,我需要打印已排序的参考书目并重置计数器,因此我需要使用defernumbers=true并且需要\nocite{*}结合实际引用使用。我发现当缺少一个键时,所有编号都会设置为零。显然,对于所有键都存在的最终文档来说,这不是问题,但在编写文档的过程中,这是一个问题。您有办法纠正这个问题吗?

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

\usepackage{filecontents}
\begin{filecontents}{mabiblio.bib}
@misc{A-01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  location = {Location},
  publisher = {Publisher},
}
@article{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {1},
}
@article{C04,
  author = {Cuthor 2, C.},
  year = {2004},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {2},
}
@article{B03,
  author = {Buthor 2, C.},
  year = {2004},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {1},
}
\end{filecontents}
\addbibresource{mabiblio.bib}

\begin{document}

\cite{authorA-01}% \cite{B02} \cite{C03}
\section{Biblio}

\nocite{*}

\printbibliography

\end{document}

答案1

defernumbers功能通过将标签编号写入.aux文件来工作。biblatex只有在不再需要 Biber 调用时才会这样做,因为预期 Biber 调用可能会改变排序,这意味着标签编号也会改变。

如果输入密钥缺失或错误,您将始终收到 Biber 重新运行请求,这意味着标签编号永远不会写入文件中.aux

如果您需要在草稿阶段引用未定义的输入键,也许您可​​以禁用defernumbers

如果您坚持的话,即使有 Biber 重新运行请求,也defernumbers有一种方法可以将标签编号写入。.aux

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

\makeatletter
\blx@AtEndDocument{%
  \iftoggle{blx@defernumbers}
    {\iftoggle{blx@runbiber}
      {\def\do#1{\blx@auxwrite\@mainaux{}{#1}}
       \dolistloop\blx@localnumaux}
      {}}
    {}}
\makeatother

\begin{filecontents}{\jobname.bib}
@misc{A-01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  location = {Location},
  publisher = {Publisher},
}
@article{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {1},
}
@article{C04,
  author = {Cuthor 2, C.},
  year = {2004},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {2},
}
@article{B03,
  author = {Buthor 2, C.},
  year = {2004},
  title = {Charlie},
  journaltitle = {Journal title},
  volume = {1},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cite{authorA-01}% \cite{B02} \cite{C03}
\section{Biblio}

\nocite{*}

\printbibliography
\end{document}

未定义引用,但参考文献仍按预期编号。

相关内容