0

When I print the references, the entry shows the urldate instead of no date. How can I suppress the urldate?

bibliography.bib:

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

Result: Test (2022) Expected: Test (n. d.)

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

I tried the following solutions: src

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

Which leads to n. d. for entries with valid year field

and this solution

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

1 Answer 1

0

You need a \field{year} in your \DeclareLabeldate definition right after the \field{date} so that the legacy field is recognised. This is slightly counter-intuitive, but should be resolved in the upcoming biblatex release, see https://github.com/plk/biblatex/issues/714.

For now use

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

Hello (SL, n.d.) and (Myself, 2020)

1
  • Works perfectly. Thank you so much!
    – S_L
    Nov 19, 2022 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .