-1

My .rmd file fails to compile when including citations as a .bib file. I attached the code and error message here and very appreciate if someone could help.

enter image description here

Michael Harper
  • 14,721
  • 2
  • 60
  • 84
  • 1
    Please can you add the code question, correctly formatted instead of an image? https://meta.stackexchange.com/q/22186/387544 – Michael Harper May 06 '18 at 09:46

1 Answers1

1

The indentation of the YAML options is important. You currently have bibliography within the output section, but it should be placed in as a top-level YAML.

title: "Title"
author: "Author"
output: 
  pdf_document:
    keep_tex: true
bibliography: bib.bib

Edit: Make sure you have moved the bibliography out of the pdf_document options completely, as follows:

author: "Author"
output: 
  pdf_document:
    keep_tex: true
    fig_caption: yes
    number_sections: yes
bibliography: bib.bib
---
Michael Harper
  • 14,721
  • 2
  • 60
  • 84
  • Hi, Mikey. I did place the bibliography on the top-level YAML as your suggestion, but it still doesn't work. The error message was same as shown in the above figure. However, it run well if removing the **bibliography**. Any further suggestion? Thanks. – Erjia Ge May 07 '18 at 04:15
  • Updated the answer to resolve what I think you have done wrong. I am always happy to help new users, but it would help you if you were to read the guidance about asking questions on StackOverflow: https://stackoverflow.com/help/how-to-ask . Most importantly for you, you need to be able to provide a code example which allows others to replicate your problem. Attaching a screenshot just requires other people to manually type out the code: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. Writing better questions will make it easier for people to help – Michael Harper May 07 '18 at 09:13
  • Many thanks, Mikey. Finally! I got it going through. I think the problem was incorrect pathways for the .bib file and did not place the bibliography on the top-level YAML. Thanks again. Erjia – Erjia Ge May 07 '18 at 15:55