Search code examples
referencer-markdownbibliography

No bibliography in PDF R Markdown output despite .bib file


I writing a document in R Markdown and want to add a bibliography using a .bib file created by Citava. My basic file is as follows:

---
title: "Some text"
bibliography: Test4.bib
---

Some Text

# References

If I knit my document the references at the end of the document are missing in the pdf output. Where is my mistake?


Solution

  • R Markdown will by default only display the bibliography for items cited in the text, as shown here.

    As outlined in this GitHub issue, you can force the display of all items in a bibligraphy by using nocite: '@*'. The following reproducible example creates an example test.bib containing two bibliography entries, and no reference is made to these directly within the text:

    ---
    title: "Untitled"
    output: pdf_document
    bibliography: test.bib
    ---
    
    ```{r, include = FALSE}
    knitr::write_bib(x = c("rmarkdown", "knitr"), file = "test.bib")
    ```
    
    Text in which I make no reference to any bibliography.
    
    # References
    
    ---
    nocite: '@*'
    ...
    

    enter image description here