Search code examples
rknitrr-markdownbibtex

Include the text of a `bibentry` in the (R)markdown text body output


I have been looking for a solution to include the full text of a reference item (bibentry) in the body of the (R)markdown text document, that is, before the reference list. This can be done with LaTeX (https://tex.stackexchange.com/questions/49048/how-to-cite-one-bibentry-in-full-length-in-the-body-text). Can it be done with (R)markdown?


Solution

  • A reasonable solution is to read and parse the bibliography database using, for example, the R-package bibtex and then capture.output of print as a character string, which can then be used to include the full text of a reference item (bibentry) in the body of the (R)markdown text document.

    For example:

    ```{r, echo=FALSE}
    biblio <- bibtex::read.bib("my-biblio-database.bib")
    ```
    

    Then, in line, use:

    `r capture.output(print(biblio["my-bibkey"]))`
    

    which will print the reference text.