刪除空年份欄位 biblatex ieee 樣式的括號

刪除空年份欄位 biblatex ieee 樣式的括號

透過使用 biblatex ieee 樣式,我發現即使欄位「year」未定義,引用也會顯示空括號。如何在不更改 biblatex.bst 的情況下刪除它?

\documentclass{article}

\usepackage[style=ieee,backend=bibtex]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\x.bib}
@ELECTRONIC{MEMSnet,
  title = {What is {MEMS}?},
  organization = {MEMSnet},
  url = {http://www.memsnet.org/mems/what_is.html},
  urldate = {Dec. 01, 2013}
}
\end{filecontents}

\addbibresource{\x.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

我有

()。什麼是微機電系統? MEMSnet,[線上]。可用的:http://www.memsnet.org/mems/what_is.html

這不是正確的引用風格。我想擁有:

什麼是微機電系統? MEMSnet,[線上]。可用的:http://www.memsnet.org/mems/what_is.html

非常感謝

答案1

我們ieee.bbx找到以下幾行

\DeclareBibliographyDriver{online}{%
  [...]
  \setunit{\adddot\addspace}%
  \printtext[parens]{\usebibmacro{date}}%
  \setunit{\adddot\addspace}%
  [...]

因此biblatex嘗試使用date巨集(實際上預設為\printdate)並將其輸出括在括號中。如果它沒有印製任何內容,那麼,一個空字串就會被括在括號中,從而得到上面的結果。

明顯的解決方法是為條目提供一個date字段(畢竟,[幾乎]每個圍脖條目都應該有一個字段,另請參閱上面 Joseph Wright 的評論),@online但這對於某些資源來說可能很困難並且完全不可能。

由於我們不想重寫整個@online驅動程式(這是解決問題的明顯方法),因此我們使用xpatch

加載\usepackage{xpatch}此程式碼並將其放入您的序言中

\xpatchbibdriver{online}
  {\printtext[parens]{\usebibmacro{date}}}
  {\iffieldundef{year}
    {}
    {\printtext[parens]{\usebibmacro{date}}}}
  {}
  {\typeout{There was an error patching biblatex-ieee (specifically, ieee.bbx's @online driver)}}

\printtext[parens]{\usebibmacro{date}}它將用一個(或多或少複雜的)構造來替換上面討論的有問題的行( ),在該構造中我們檢查是否存在一個year字段(即足夠的日期字段)並且僅當滿足該條件時(即僅當一年存在時;當然,這裡我們假設這year是參考書目中日期輸出的最低要求)我們繼續打印日期,否則什麼也不做。

\documentclass{article}
\usepackage[style=ieee,backend=bibtex]{biblatex}
\usepackage{xpatch}

\begin{filecontents}{\jobname.bib}
@ELECTRONIC{MEMSnet,
  title = {What is {MEMS}?},
  organization = {MEMSnet},
  url = {http://www.memsnet.org/mems/what_is.html},
  urldate = {2013-12-01},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\xpatchbibdriver{online}
  {\printtext[parens]{\usebibmacro{date}}}
  {\iffieldundef{year}
    {}
    {\printtext[parens]{\usebibmacro{date}}}}
  {}
  {\typeout{There was an error patching biblatex-ieee (specifically, ieee.bbx's @online driver)}}

\begin{document}
  \nocite{MEMSnet,wilde,markey}
  \printbibliography
\end{document}

在此輸入影像描述

相關內容