如何删除引用中的空字段的括号?

如何删除引用中的空字段的括号?

同一问题已得到解答这里但这个解决方案对我来说不起作用,因为我不确定空字段是什么。有没有办法删除所有空项?

也许是类似

\AtEveryBibitem{%

  if entry is empty {
             \clearfield{} 
  }
}

这些是我对 biblatex 的属性:

\usepackage[
backend=biber,
backref=false,
sorting=nyt,
style=authoryear,
citestyle=authoryear]{biblatex}

参考文献如下:

在此处输入图片描述

我刚刚使用的 .cfg 文件如下:

\ProvidesFile{biblatex.cfg}

\DeclareNameAlias{sortname}{last-first}

% Put titles in quotes for most types
\DeclareFieldFormat
  [online,article,inbook,incollection,inproceedings,thesis,unpublished,patent]
  {title}{\mkbibquote{#1\addcomma}}
\DeclareFieldFormat
  [book]
  {title}{\mkbibemph{#1\addcomma}}

\DeclareFieldFormat
  [inbook,incollection,inproceedings]
  {booktitle}{\mkbibemph{#1\addcomma}}

% Attempted Fixes for ONLINE entries
\DefineBibliographyStrings{english}{%
  url = {available online at},
  }

\DeclareFieldFormat{url}{\bibstring{url}\space\url{#1}}
\DeclareFieldFormat{urldate}{\printtext{accessed}\space#1}

\renewbibmacro*{url+urldate}{%
  \printtext[parens]{%
   \printfield{url}\addsemicolon\space
   \printurldate
  }}

% Year formatting
\renewbibmacro*{date+extrayear}{%
  \iffieldundef{\thefield{datelabelsource}year}
    {}
    {\printtext{%
       \printfield{\thefield{datelabelsource}year}%
       \printfield{extrayear}}}}%
\renewbibmacro*{date}{%
  \iffieldundef{month}
    {}
    {\printdate}}%
\renewbibmacro*{issue+date}{%
  \ifboolexpr{
    test {\iffieldundef{issue}}
    and
    test {\iffieldundef{month}}
  }
    {}
    {\printtext{%
       \printfield{issue}%
       \setunit*{\addspace}%
       \printdate}}%
  \newunit}

% Fix names
\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\labelnamepunct}{\addperiod\space }
\renewcommand*{\finalnamedelim}{,\addspace and\addspace }

% Fix "in"
\renewbibmacro*{in:}{%
  \printtext{%
    in\space}}

% Gotta get rid of the "in" before journal title
\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

% Make (Volume:Issue)
\newbibmacro*{volume+number+eid}{%
  \printtext[parens]{%
  \printfield{volume}%
  \setunit*{:}%
  \printfield{number}}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

% Fix editor
\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
    {}
    {\printnames[byeditor]{editor}%
     \setunit{\addspace}%
     \printtext[parens]{\usebibmacro{apaeditorstrg}{editor}}%
     % \usebibmacro{byeditor+othersstrg}%
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\newbibmacro*{apaeditorstrg}[1]{%
  \iffieldundef{#1type}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
       {\bibstring{editors}}
       {\bibstring{editor}}}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
         {\bibcpstring{type\thefield{#1type}s}}
         {\bibcpstring{type\thefield{#1type}}}}}

% Fix appearance of , with name lists of two
\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}
\endinput

艾西斯菲纳尔

 \LoadClass[10pt,letterpaper]{article}

答案1

通常,biblatex当字段使用 打印时,会自动删除所有空字段的格式\printfield。但是,如果通过\printtext或其他方式应用空内容的格式,则不能自动删除。在这种情况下,样式必须手动检查 的内容是否\printtext为空,或者必须(默认或不默认)假定内容不为空。

如果检测到字段为空,则发出 根本没有帮助,\clearfield因为对于大多数相关意图和目的而言,这不会改变相关字段的状态。空字段已被清除。


在你之前的问题中如何在参考文献部分提及引用的位置?我们确定您使用biblatex.cfg来自https://github.com/rschuetzler/latex-icis-template/blob/master/biblatex.cfg

除了其他(过时且可疑的)构造外,该文件还包含

\renewbibmacro*{url+urldate}{%
  \printtext[parens]{%
   \printfield{url}\addsemicolon\space
   \printurldate
  }}

此代码隐式地假设每个条目都有一个url或至少一个urldate。对于许多条目类型,此假设不必成立。即使 不是url或,代码也将始终打印一对括号urldate

更合理的定义可能是

\renewbibmacro*{url+urldate}{%
  \iffieldundef{url}
    {}
    {\printtext[parens]{%
       \printfield{url}
       \setunit{\addsemicolon\space}%
       \printurldate}}}

仅当存在 时,才会在括号中打印url和字段(如果没有 ,则明确不显示)。特别是您的示例条目不应显示一对空的括号。urldateurlurldateurl

请注意,该问题在原始模板中并不明显,因为使用biblatex选项调用url=false,这实质上意味着仅对字段很可能不为空的条目url+urldate调用该宏。@onlineurl

相关内容