I'm trying to write a scientific manuscript entirely in an R project. R markdown and bookdown have gotten me 99% of the way there, but I still can't figure out how to properly reference R packages in the bibliography. The author, title, and year show up, but I can't get it to add the version information and URL.
I put a minimum working example in a GitHub repository. You can download that and knit the .Rmd file, or follow these steps.
- Create a file called references.bib with an entry for an R package. This example uses a lightly edited version of the BibTeX entry generated using
citation()
for packagepracma
.
@Manual{R-pracma,
title = {pracma: Practical Numerical Math Functions},
author = {Hans W. Borchers},
year = {2021},
note = {R package version 2.3.3},
url = {https://CRAN.R-project.org/package=pracma},
}
-
Download a citation style language (CSL) template. I used the CSL for The Company of Biologists.
-
Create an .Rmd file with the following content.
---
title: "bibliographyquestion"
output:
bookdown::word_document2
bibliography: references.bib
csl: "the-company-of-biologists.csl"
---
[@R-pracma]
- Knit the .Rmd file
The output Word document looks like this:
My question is, how do I get the version number and URL in there? They're in the note
and url
fields of the BibTeX entry, respectively. I've tried editing the CSL to support type Manual
, but it looks like the BibTeX entries get edited during an intermediate step because @Manual{...}
entries (like R packages) get picked up by the book
entry type.
Right now I have to manually edit my bibliography's R package entries every time I knit a new version, but I'm sure there has to be a better way. Thanks in advance for your help!