2

I am trying to use reference in the R Markdown. When I try to export the markdown to pdf or anything, I receive no error!

But the references do not appear:

I have it as this in the beginning:

---
title: "Gap"
author: "xyz"
date: "19/09/2018"
bibliography: ref.bib
output: pdf_document
---

I changed the name to ref2.bib (only in the R file) and in that case I do get an error saying it does not find a file... So based on that I do know it is finding the file but it is not displaying the references... (I have also tried using different references). What could I be doing wrong?

If there would be an error it would be easier to reproduce, but I see nothing that's the issue: It's a pretty dumb example enter image description here And the bib file is in the same folder enter image description here

And I don't see the bib.ref

Chicago1988
  • 970
  • 3
  • 14
  • 35
  • Please make this question *reproducible*. This includes a small representative markdown document in addition to the yaml header you've provided. – r2evans Sep 19 '18 at 17:29
  • In latex I believe one has to compile a document twice to get the bibliography to show up. I don't know why, but that is always my experience. Perhaps your problem is a variant on that issue. – meh Sep 19 '18 at 18:31

2 Answers2

4

You need to reference your bibliography file in your .Rmd file.

So in your example would have to add:

[@valiant1990bridging]

The below thread has quite a useful example:

Including Bibliography in RMarkdown document with use of the knitcitations

RK1
  • 2,384
  • 1
  • 19
  • 36
1

I was not citing it. It is my first time using this, I wanted to do a quick example, but apparently if you do not cite it with the @ symbol, there reference will not appear; and it makes sense you don't want to reference stuff you don't cite at all.

Chicago1988
  • 970
  • 3
  • 14
  • 35