citation() give an incomplete bibtex format

When using citation("package") the bibtext format is not complete in the sense that is not posible to insert in a quarto document

citation("dplyr")
To cite package ‘dplyr’ in publications use:

Wickham H, François R, Henry L, Müller K, Vaughan D (2023).
dplyr: A Grammar of Data Manipulation. R package version
1.1.4, https://CRAN.R-project.org/package=dplyr.

A BibTeX entry for LaTeX users is

@Manual{,
title = {dplyr: A Grammar of Data Manipulation},
author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan},
year = {2023},
note = {R package version 1.1.4},
url = {CRAN: Package dplyr},
}

I was expecting:

@Manual{Wickham2023,
title = {dplyr: A Grammar of Data Manipulation},
author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan},
year = {2023},
note = {R package version 1.1.4},
url = {CRAN: Package dplyr},
}

1 Like

As per ?citation, you should get the result with:

toBibtex(citation("dplyr"))
#> @Manual{,
#>   title = {dplyr: A Grammar of Data Manipulation},
#>   author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan},
#>   year = {2023},
#>   note = {R package version 1.1.4},
#>   url = {https://CRAN.R-project.org/package=dplyr},
#> }

Created on 2024-06-26 with reprex v2.1.0

Thank you!

But how do you do cross-reference in a quarto document? It is not possible.

[@Wickham2023]

Have you taken a look here?

Yes, but the problem is with the identifier.

From the quarto Citations help

Quarto uses the standard Pandoc markdown representation for citations (e.g. [@citation]) — citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of ‘@’ + the citation identifier from the database.

Now, what is the identifier in the bibtex style citation generated by citation("dplyr")?

Ah ok! I see your issue. Look into this small example:

---
title: "try-cite"
format: html
bibliography: packages.bib
---

## Trying citations

```{r}
knitr::write_bib(x="tidyverse", file="packages.bib")
```


blah blah blah [@R-tidyverse]

The function knitr::write_bib() always writes the tag as "R-{packagename}".

1 Like

Thank you very much, that was what I was looking for.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.