4

I am trying to add a last accessed field to web references in a Quarto PDF. Here is a minimal example of a qmd file:

---
title: "How to cite a URL with access date"
format: pdf
bibliography: references.bib
---

I am using @stackoverflow1, @stackoverflow2 and @stackoverflow3.

# References

::: {#refs}
:::

This is references.bib:

@online{stackoverflow1,
  title = {Stack Overflow with note},
  url   = {https://stackoverflow.com/},
  year  = {2022},
  note  = {https://stackoverflow.com/, last accessed on 2022-12-30}
}

@online{stackoverflow2,
  title   = {Stack Overflow with urldate},
  url     = {https://stackoverflow.com/},
  year    = 2022,
  urldate = {2022-12-30}
}

@online{stackoverflow3,
  title    = {Stack Overflow with accessed},
  url      = {https://stackoverflow.com/},
  year     = {2022},
  accessed = {2022-12-30}
}

The output is,

enter image description here

As you can see, the note, urldate and accessed fields are all ignored. I have tried using different csl files, e.g. APA and Harvard Educational Review. I have also tried the instructions for doing this in Latex in this and this post. I have also changed @misc to @online. None of these seem to make any difference.

How do you add a date accessed field to a Quarto PDF reference?

Expected output

References

"Stack Overflow", 2022, https://stackoverflow.com/, last accessed on 2022-12-30

SamR
  • 8,826
  • 3
  • 11
  • 33

2 Answers2

5

When used with CSL, then urldate is the correct way to add the access date to a reference. The used citation style must support that information, or otherwise it won't be shown. You can go to the citation style repository and search for "accessed" (which is the key used by CSL for this information). This will bring up all styles that include this info in the entry.

https://github.com/citation-style-language/styles/search?q=accessed

Such styles are commonly called "author date styles", so we could also search for those in the Zotero database. To use a style, download it and pass it via the csl metadata key.

tarleb
  • 19,863
  • 4
  • 51
  • 80
  • 1
    I did try to do just this but I wasn't sure that `"accessed"` was the correct term to search for and I didn't know about that repo, so this is an extremely useful response, thanks. – SamR Dec 30 '22 at 09:00
  • This is really an informative and useful answer. I have just bookmarked it. – shafee Dec 30 '22 at 09:11
  • 1
    @shafee Thanks, same for your answer! I learned about the `biblatexoptions` setting, didn't know about that one before. – tarleb Dec 30 '22 at 09:13
3

You need to tell Quarto to use biblatex using cite-method yaml option.

---
title: "How to cite a URL with access date"
format: pdf
bibliography: references.bib
cite-method: biblatex
biblatexoptions:
  - citestyle = authoryear
---

I am using @stackoverflow1, @stackoverflow2 and @stackoverflow3.

# References

::: {#refs}
:::

URL access date in Quarto pdf references


accessed field is still being ignored but urldate and note is working as intended.

shafee
  • 15,566
  • 3
  • 19
  • 47
  • Thanks this is really helpful. The only thing is that the references now appear as e.g. _Stack Overflow with note [2]_, rather than _Stack Overflow with note (2022)_. This is the case even when I use either of the two `csl` files I linked in the question. Is there a way around this? – SamR Dec 30 '22 at 08:48
  • 1
    yes, see the edit. `biblatex` has actually a lot options to control citations. – shafee Dec 30 '22 at 08:53
  • Thank you. I was reading about the `biblatex` options but I couldn't work out that key value pairs had to be in the form of `citestyle = authoryear`, rather than the typical `yaml` form of `citestyle: authoryear`. I don't know how you were able to but very much appreciated. – SamR Dec 30 '22 at 08:57
  • 1
    Got this idea from skimming through this [pandoc manual](https://pandoc.org/MANUAL.html) a while ago. – shafee Dec 30 '22 at 09:04