0

I have a bib file which contains an online source. This bib file is used across multiple documents, written at different times, citing this online source. Compilation is done using Biber & BibLatex.

Now I have to adjust the date on the source to properly reflect when I accessed this Ressource. But when I do this in the bib file itself, all my documents now have an incorrect date.

My goal is to set the access date per document, but take all the other data from my bib file. Is there any way to override entry options per document?

1

1 Answer 1

2

When I read the title of the question, I immediately thought of the crossref feature shown in What is the Bibtex crossref field used for?, which @samcarter_is_at_topanswers.xyz already linked in the comments. But for your use case I'd probably prefer a Biber sourcemap to override field values easily from within your .tex document.

Compare the value from the .bib file (2020-02-02) to the value set by the sourcemap and shown in the output (2023-02-20). Note that the sourcemap only works if a urldate is present in the .bib entry (it will not add urldates to entries that don't have them yet - that could be done, but would probably be overkill).

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear]{biblatex}

\DeclareSourcemap{
  \maps{
    \map[overwrite=true]{
      \step[fieldsource=urldate, final]
      \step[fieldset=urldate,  fieldvalue={2023-02-20}]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@book{elk,
  author    = {Anne Elk},
  title     = {A Theory on Brontosauruses},
  year      = {1972},
  publisher = {Monthy \& Co.},
  location  = {London},
  url       = {https://example.edu/~elk/bronto},
  urldate   = {2020-02-02},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson,elk}

\printbibliography
\end{document}

Elk, Anne (1972). A Theory on Brontosauruses. London: Monthy & Co. url: https://example.edu/~elk/bronto (visited on 20/02/2023).

The sourcemap shown here applies to all entries alike. If you need to give different dates for different entries, you can filter by entrykey, but of course that might get messy rather quickly

\DeclareSourcemap{
  \maps{
    \map[overwrite=true]{
      \step[fieldsource=entrykey, match=\regexp{\Aelk\Z}, final]
      \step[fieldsource=urldate, final]
      \step[fieldset=urldate,  fieldvalue={2023-02-20}]
    }
  }
}

Compare also biblatex: remove field from specific entry.

1
  • Yeah I also forgot about crossrefs ^^' But this solution is way easier to wrap into a simple command in the documentclass which can then be invoked from each document for the required sources.
    – CShark
    Commented Feb 20, 2023 at 18:13

You must log in to answer this question.

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