Is it possible to insert the full reference of an article in the middle of a Rmarkdown document using citation keys?

636 Views Asked by At

Here I learn how to insert citations in the middle of a text and generate a full bibliography at the end of the document. I wonder whether it is possible to have an output like this using citation keys:

Bla bla bla.

Watson, J. D., & Crick, F. H. (1953). Molecular structure of nucleic acids. Nature, 171(4356), 737-738.

Bla bla bla.

1

There are 1 best solutions below

0
On

In-text full references/citations in RMarkdown using Bibtex-package.

Solution using bibtex-package proposed by Samuel-Rosa. An example with citations for packages:

  1. Example .bib file
knitr::write_bib("R"), "example.bib")
  1. Read your .bib file into R.
refs <- bibtex::read.bib("example.bib")
  1. Using in-line chunks, select the entry of interest, e.g. R-base, print the entry, and "capture" it as character for RMarkdown output.
Example full reference for R:  
> `r capture.output(print(refs["R-base"]))`

Output:

Example full reference for R:

R Core Team (2021). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. <URL: https://www.R-project.org/>.