Use citation() in R Markdown to automatically generate a bibliography of R packages

Thanks for sharing. I looked over the other solution and it looks a little convoluted to me. I tried to maintain as much of the "normal" R Markdown workflow as possible. The knitr::write_bib() function basically does exactly what the citeR() function does, so I don't see too much added value. I am also less familiar with lua filters, but I guess if it works, it works.

@mattwarkentin do you know if it is possible to use csl files with your solution? I tried to put csl: somestyle.csl in the YAML but it seems that the style specified in header.tex overrules the csl style and I can't find a way to easily use the csl file with biblatex.

This solution supports any biblio-style supported by the biblatex package. CSL files are used by pandoc-citeproc, which is pandoc's system for cross-document handling of bibliographies. This solution relies on using specific functions (\DeclareBibliographyCategory, \addtocategory) from the biblatex package, and so it forces the use of biblatex over pandoc-citeproc.

Here are some of the supported styles. Many more styles are downloadable.

I created a GitHub repository here that is an updated version of the files I shared here previously. I restructured the documents so the header file is no longer necessary. Everything is handled straight from the RMarkdown document, to make the workflow easier. Consider using these files instead.

1 Like

@mattwarkentin okay I understand, thanks for summarizing your solution with your GitHub repo. Small review:

  • your solution is made in line with the R Markdown workflow but prevents the use of csl files
  • the solution provided on SO is more complex to understand but allows the use of csl files.

Both of these solutions might have other drawbacks but I didn't use them enough to detect them.

Thanks again for your help :slight_smile:

No problem, happy to help.

I am not sure if the StackOverflow solution still supports csl, but if the bibliographies are handled by pandoc-citeproc then csl is probably still supported.

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