xyz04
xyz04

Reputation: 21

No cite function writing "no cite" at the top of my Rmd document

I am trying to figure out how to get a reference sheet without citing sources in text, from what I understand I am supposed to use:

# References
---
nocite: '@*'
...

the thing is when I do this when I knit the document all I get is

enter image description here

but when I add that section of nocite code into the YAML header like this:

enter image description here

it produces a reference sheet like normal but then at the top of the document i get this:

enter image description here

Could someone explain how I can create a bibliography without using in-text citations.

Upvotes: 0

Views: 291

Answers (1)

duckmayr
duckmayr

Reputation: 16910

Following the advice from Rstudio here, you need to format it like this:

---
title: "Stack Overflow Answer"
author: "duckmayr"
date: "1/2/2021"
output: pdf_document
nocite: | 
  @*
bibliography: refs.bib
---

(In the refs.bib file I have the following contents:)

@Article{CameronKastellec2016Are,
  author  = {Charles M. Cameron and Jonathan P. Kastellec},
  title   = {Are {S}upreme {C}ourt nominations a move the median game?},
  journal = {American Political Science Review},
  year    = {2016},
  volume  = {110},
  number  = {4},
  pages   = {778--797},
}

This results in the following document:

enter image description here

To make the difference a little more explicit, you have to change

nocite: '@*'

to

nocite: |
  @*

Update: Using natbib

If you want to use the natbib citation package, then you simply need to use the LaTeX command for generating the citations, like so:

---
title: "Stack Overflow Answer"
author: "duckmayr"
date: "1/2/2021"
output:
  pdf_document:
    citation_package: natbib
bibliography: refs.bib
---

\nocite{*}

This results in the following document:

enter image description here

Upvotes: 3

Related Questions