0

I am currently using biblatex/biber with 'chem-rsc' style for citing my references in latex. Unfortunately, with this style the date of access is not displayed for @online entries in the bibliography. Now I am trying to redefine the bibliography format for URLs, so that I'd get the following format (german):

online unter URL: >>URL<<, aufgerufen am >>urldate<<

After some research I have patched together the following code from different threads concerning this topic.

MWE:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[style=chem-rsc]{biblatex}

\begin{filecontents}{references.bib}
@Online{AgIGESTIS,
  institution  = {IFA},
  organization = {IFA},
  urldate    = {2023-01-30},
  title        = {Eintrag zu Silberiodid in der GESTIS-Stoffdatenbank},
  url          = {https://gestis.dguv.de/data?name=122731},
}
\end{filecontents}

\addbibresource{references.bib}

\NewBibliographyString{available}
\NewBibliographyString{cited}

\DefineBibliographyStrings{ngerman}{%
  available = {online unter URL},
 cited = {aufgerufen am},
}

\DeclareFieldFormat{url}{\bibstring{available}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{#1}

\renewbibmacro*{url+urldate}{%
  \printfield{url}\addcomma\space
  \printtext{\bibstring{cited}}
  \printfield{urldate}
  }
  
\begin{document}

Lorem ipsum\nocite{AgIGESTIS}

\printbibliography

\end{document}

Result:

enter image description here

While I'm getting the correct format from this in general, the urldate is not printed. Apparently the \printfield{urldate} statemend does not work here. I also tried \printurldate or \printfield{urlday}, but none of that seemed to return anything. Any idea what I am doing wrong? Is there any other way I get the date displayed?

1
  • 3
    urldate is not a "real" field, the data is in urlyear, urlmonth and urlday, you can also use \printurldate. But before redefining everything try \ExecuteBibliographyOptions[online]{url=true}. Feb 5, 2023 at 14:06

1 Answer 1

1

The urldate field in a bibliography file is parsed by biblatex resp. biber into its components urlyear, urlmonth, urlday and various other fields. This is documented in the biblatex documentation: for v3.18b (July 12, 2022) see section 4.2.4.3 "Date Component Fields":

See table 10 for an overview of how the date fields in bib files are related to the
date fields provided by the style interface.

The references table describes all resulting fields you can use in your formatting macros. Use \iffieldundef to test for existing fields.

This allows you to format dates in the most appropriate date format you want.

Thus in your redefined url+urldate bib macro you have to replace the line

\printfield{urldate}

by

\printurldate

and set the date format via options. (Thanks @moewe!)

(If needed you can implement it using low level \printfield{urlyear}-\printfield{urlmonth}-\printfield{urlday} and adding \iffieldundef tests to allow incomplete dates, e.g., without a day.)

3
  • Replacing the line fixed it. Thanks for helping out!
    – Task2602
    Feb 5, 2023 at 15:05
  • Please don't say \printfield{urlyear}-\printfield{urlmonth}-\printfield{urlday}. Instead use \printurldate and set the date format via the options.
    – moewe
    Feb 5, 2023 at 17:49
  • Thanks @moewe - changed my answer accordingly. Feb 5, 2023 at 20:01

You must log in to answer this question.

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