Biblatex,當使用 nocite 和 defernumber 呼叫未知鍵時編號為零

Biblatex,當使用 nocite 和 defernumber 呼叫未知鍵時編號為零

在我的“真實”範例中,我需要列印帶有計數器重置的排序參考書目,因此我需要使用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.

如果您堅持這樣做defernumbers,這裡有一種方法可以將標籤編號寫入,.aux即使有 Biber 重新運行請求。

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

未定義引用,但參考文獻仍如預期編號。

相關內容