biblatex:不显示日期而是显示 urldate

biblatex:不显示日期而是显示 urldate

当我打印参考文献时,条目会显示 urldate,而不是没有日期。我该如何隐藏 urldate?

bibliography.bib

@misc{test,
    title = {Test},
    url = {https://tex.stackexchange.com},
    urldate = {2022-11-17},
    author = {{SL}}
}

结果:测试(2022)预期:测试(nd)

packages

\usepackage[style=authoryear,giveninits,uniquename=init,maxbibnames=6,urldate=long,backend=biber]{biblatex}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\DeclareFieldFormat{url}{Available at\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{(Accessed: #1)}

我尝试了以下解决方案: 源码

\DeclareLabeldate{\field{date}\field{eventdate} \field{origdate}\literal{nodate}}

这导致查找具有有效年份字段的条目

和这个解决方案

MWE.tex

\documentclass{article}
\begin{filecontents*}{test.bib}
    @book{mybook,
        title = {Book title},
        author = {Myself, Me},
        year = {2020},
    }
    @misc{test,
        title = {Test},
        url = {https://tex.stackexchange.com},
        urldate = {2022-11-17},
        author = {{SL}}
    }
\end{filecontents*}

\usepackage[style=authoryear,giveninits,uniquename=init,maxbibnames=6,urldate=long,backend=biber]{biblatex}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\DeclareFieldFormat{url}{Available at\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{(Accessed: #1)}

\addbibresource{test.bib}

\begin{document}
    Hello \cite{test} and \cite{mybook}
    
\printbibliography[title=References]
\end{document}

答案1

您需要\field{year}\DeclareLabeldate定义中紧跟在后面添加一个\field{date},以便识别遗留字段。这有点违反直觉,但应该会在即将发布的biblatex版本中得到解决,请参阅https://github.com/plk/biblatex/issues/714

现在使用

\documentclass{article}

\usepackage[
  backend=biber,
  style=authoryear,
  giveninits,
  uniquename=init,
  maxbibnames=6,
  urldate=long,
]{biblatex}
\DeclareDelimFormat{nameyeardelim}{\addcomma\space}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\addcolon\space#1}}

\DefineBibliographyStrings{english}{
  urlfrom = {available at},
  urlseen = {accessed},
}

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  \literal{nodate}
}

\begin{filecontents*}{\jobname.bib}
@book{mybook,
  title  = {Book title},
  author = {Myself, Me},
  year   = {2020},
}
@misc{test,
  title   = {Test},
  url     = {https://tex.stackexchange.com},
  urldate = {2022-11-17},
  author  = {{SL}}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
  Hello \autocite{test} and \autocite{mybook}

  \printbibliography[title=References]
\end{document}

你好(SL,nd)和(我自己,2020)

相关内容