Biblatex:抑制 urldate 不起作用(\clearfield)

Biblatex:抑制 urldate 不起作用(\clearfield)

我已经阅读了很多关于类似主题的文章(例如这里或者这里)。这个解决方案对我来说不起作用,我现在有点绝望。

这就是为什么我再次问这个问题:我该如何抑制网址日期biblatex 中的字段。

我正在使用带有 Biber 2.2 的 Miktex。

我的 MCE(摘自这里):

\documentclass{article}

\usepackage[style=authoryear-icomp]{biblatex}

\AtEveryBibitem{%
\ifentrytype{book}{
    \clearfield{url}%
    \clearfield{urldate}%
}{}
\ifentrytype{collection}{
    \clearfield{url}%
    \clearfield{urldate}%
}{}
\ifentrytype{incollection}{
    \clearfield{url}%
    \clearfield{urldate}%
}{}
}

\usepackage{filecontents}

\begin{filecontents}{test-lit.bib}
@book{Abook,
  author = {AAAAbook, A.},
  year = {2001},
  title = {Alpha},
  url = {tex.stackexchange.com},
}
@online{Bonline,
  author = {BBBBonline, B.},
  year = {2002},
  title = {Bravo},
  url = {tex.stackexchange.com},
}
@collection{Ccollection,
    editor = {CCCCColletionEditor, C.},
    year = {2002},
    title = {Charlie},
    url = {tex.stackexchange.com},
    urldate = {2010-01-01},
}
@incollection{Dincollection,
    author = {DDDDincollection, D.},
    year = {2002},
    crossref = {Ccollection},
    title = {Delta},
    url = {tex.stackexchange.com},
}
\end{filecontents}

\addbibresource{test-lit.bib}

\nocite{*}

\listfiles

\begin{document}

Abc.

\printbibliography

\end{document}

我的文档如下所示:

图片
(来源:ahschulz.de

我也很困惑,在最后一篇文章中提到了urldate,但是bib-File中没有urldate。

答案1

根据moewe的评论,urldate分为urlyear和。删除urlmonth即可解决问题。urldayurlyear

此 MCE 的工作原理如下:

\documentclass{article}

\usepackage[style=authoryear-icomp]{biblatex}

\AtEveryBibitem{%
\ifentrytype{book}{
    \clearfield{url}%
    \clearfield{urlyear}%
}{}
\ifentrytype{collection}{
    \clearfield{url}%
    \clearfield{urlyear}%
}{}
\ifentrytype{incollection}{
    \clearfield{url}%
    \clearfield{urlyear}%
}{}
}

\usepackage{filecontents}

\begin{filecontents}{test-lit.bib}
@book{Abook,
  author = {AAAAbook, A.},
  year = {2001},
  title = {Alpha},
  url = {tex.stackexchange.com},
}
@online{Bonline,
  author = {BBBBonline, B.},
  year = {2002},
  title = {Bravo},
  url = {tex.stackexchange.com},
}
@collection{Ccollection,
    editor = {CCCCColletionEditor, C.},
    year = {2002},
    title = {Charlie},
    url = {tex.stackexchange.com},
    urldate = {2010-01-01},
}
@incollection{Dincollection,
    author = {DDDDincollection, D.},
    year = {2002},
    crossref = {Ccollection},
    title = {Delta},
    url = {tex.stackexchange.com},
}
\end{filecontents}

\addbibresource{test-lit.bib}

\nocite{*}

\listfiles

\begin{document}

Abc.

\printbibliography

\end{document}

答案2

这里有一个简单的解决方案:使用包url=false选项biblatex

文献引用biblatex

url=true,false (default: true)

此选项控制是否 url打印字段和访问日期。此选项仅影响url信息可选的条目类型。url条目@online字段始终会打印。

结果:

在此处输入图片描述

代码:

\documentclass{article}

\usepackage[style=authoryear-icomp,url=false]{biblatex}

\usepackage{filecontents}
\pagestyle{empty}

\begin{filecontents}{test-lit.bib}
@book{Abook,
  author = {AAAAbook, A.},
  year = {2001},
  title = {Alpha},
  url = {tex.stackexchange.com},
}
@online{Bonline,
  author = {BBBBonline, B.},
  year = {2002},
  title = {Bravo},
  url = {tex.stackexchange.com},
}
@collection{Ccollection,
    editor = {CCCCColletionEditor, C.},
    year = {2002},
    title = {Charlie},
    url = {tex.stackexchange.com},
    urldate = {2010-01-01},
}
@incollection{Dincollection,
    author = {DDDDincollection, D.},
    year = {2002},
    crossref = {Ccollection},
    title = {Delta},
    url = {tex.stackexchange.com},
}
\end{filecontents}

\addbibresource{test-lit.bib}

\nocite{*}

\listfiles

\begin{document}

Abc.

\printbibliography

\end{document}

相关内容