R-markdown does not produce citation list with Bibtex. No error messages

rmarkdown

#1

I asked this question at stackexchange, but received no answers.

R Markdown produces a document without error but ignores my bibtex file.
The citations are ignored and the reference list at the end of my document is empty.

... blah, blah [@sde] [@iacus].

My r-markdown chunk file is as follows:
title: 'CF: A Package'

author: Paul J. Ossenbruggen

date: '2018-01-25'

type: default

output: html_document: toc: no theme: united highlight: tango bibliography: CF.bibtex link_citations: true

css: styles.css

Removing css: styles.css make no difference.
sessionInfo()
R version 3.4.3 (2017-11-30) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.3

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] Basic_0.1.0

loaded via a namespace (and not attached): [1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rsconnect_0.8.8 rprojroot_1.3-2 htmltools_0.3.6 [7] tools_3.4.3 yaml_2.1.18 Rcpp_0.12.15 stringi_1.1.6 rmarkdown_1.9 knitr_1.20
[13] stringr_1.3.0 digest_0.6.15 evaluate_0.10.1

My bibtex file is:
@book{iacus, Author = {Stefano Iacus}, Publisher = {Springer-Verlag}, Title = {Simulation and Inference for Stochastic Differential Equations: With R Examples}, Year = {2008} }

@Manual{sde, title = {sde: Simulation and Inference for Stochastic Differential Equations}, author = {Stefano Maria Iacus}, year = {2016}, note = {R package version 2.0.15}, url = {https://CRAN.R-project.org/package=sde}, }

I have searched for a solution.
The following suggestion of establishing a path to my CF.bibtex made no difference.

PJO:Basic PJO$ (setq reftex-default-bibliography '(/Users/PJO/Desktop/Basic/CF.bibtex"))


#2

Hi @pjo,

Currently, the formatting makes it pretty hard to read your post. Could you please add backticks around the code so that it's separated from the prose visually?

In most cases this can be accomplished with a reprex, but I'm not sure it works in this scenario (since your having a bibtex problem).

```
code goes here
```

#3

R Markdown produces a document without error but ignores my bibtex file.
The citations are ignored and the reference list at the end of my document is empty.

... blah, blah [@sde] [@iacus].

My r-markdown chunk file is as follows:

title: 'CF: A Package'
author: Paul J. Ossenbruggen
date: '2018-01-25'
type: default
output: html_document: toc: no theme: united highlight: tango bibliography: CF.bibtex link_citations: true
css: styles.css

Removing css: styles.css makes no difference.

sessionInfo()
R version 3.4.3 (2017-11-30) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.3

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] Basic_0.1.0

loaded via a namespace (and not attached): [1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rsconnect_0.8.8 rprojroot_1.3-2 htmltools_0.3.6 [7] tools_3.4.3 yaml_2.1.18 Rcpp_0.12.15 stringi_1.1.6 rmarkdown_1.9 knitr_1.20
[13] stringr_1.3.0 digest_0.6.15 evaluate_0.10.1

My bibtex file is:

@book{iacus, Author = {Stefano Iacus}, Publisher = {Springer-Verlag}, Title = {Simulation and Inference for Stochastic Differential Equations: With R Examples}, Year = {2008} }

@Manual{sde, title = {sde: Simulation and Inference for Stochastic Differential Equations}, author = {Stefano Maria Iacus}, year = {2016}, note = {R package version 2.0.15}, url = {https://CRAN.R-project.org/package=sde}, }

I have searched for a solution without success. For example, the following suggestion of establishing a path to my CF.bibtex made no difference.

PJO:Basic PJO$ (setq reftex-default-bibliography '(/Users/PJO/Desktop/Basic/CF.bibtex"))

According to the bookdown and blogdown manuals, I am following proper protocols.

Thanks,
Paul


#4

Is that the exact formatting of your YAML header? If so, you'll need to format it with the kind of indenting shown in the RMarkdown docs. The frontmatter is whitespace-sensitive, so, for example:

---
title: "Habits"
output:
  html_document:
    theme: null
    highlight: null
    css: styles.css
---

I'm just pulling one of the examples from the site, but the same hold for bibliographies, etc.
https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html#bibliographies


#5

Hi Mara,

I have read RMarkdown.docs. Unfortunately, there is no information about bibliographies in it. Regardless, I played around with the front matter and used a trial and error approach to find out how it works.

While the following does not produce a reference list or execute [@key] commands, the placement items in front matter as you warned me. For example, alignment of bibliography is crucial. If not aligned correctly, a error 83 appears. type: default is needed for yaml. I deleted it and Knitr was halted immediately.

Please let know if you other things that I could try.

By the way, I have simplified my code.

Thanks,
Paul

---
title: 'CF: A _Stochastic_ Car-Following Package'
author: Paul J. Ossenbruggen
date: '2018-01-25'
type: default
output: 
  html_document:
    toc: no
    theme: null
    highlight: null
  bibliography: CF.bibtex
  link_citations: true
---

This command is needed:

library(Basic)

This command is not needed:

knitr::opts_chunk$set(echo = FALSE)

At least, it does seem to affect the output after deleting it.


#6

This link (which I also put above) is literally to a page called "Authoring bibliographies and citations": https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html


#7

I think that the bibliography line in the yaml should be without indentation.


#8

Hi,

I have seen this document. In fact, I use its suggestion to use “.bibtex” for CF.bibtex. It is suppose to force it to open.

What is the YAML metadata section?

Pandoc can automatically generate citations and a bibliography in a number of styles. In order to use this feature, you will need to specify a bibliography file using the bibliography metadata field in a YAML metadata section. 

What I receive the follow error when I do not indent biblio…

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 11, column 17
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous> -> .Call
Execution halted

Paul


#9

The R Markdown works with:

---
title: "tfuhp: .."
author: "Paul J. Ossenbruggen"
date: "2018-01-25"
bibliography: "/Users/PJO/Desktop/Basic/CF.bib"
output: html_document
---
  1. I removed the "toc" and other commands that control the formatting. See earlier replies. The chunk is more complex.
  2. I used double quotes "..." in place of single quotes '...'
  3. I placed the bibliography command above the output command.
  4. I replaced CF.bib with the path, "/Users/PJO/Desktop/Basic/CF.bib"

Even though R Markdown works by producing a reference list and properly referencing an item, I receive the following error. Line 6 is output: html_document

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 6, column 6
> 

If I specify bibliography: "CF.bib" or bibliography: CF.bib, I receive the following error:

Error running filter /usr/local/bin/pandoc-citeproc:
Filter returned error status 1
Error: pandoc document conversion failed with error 83
Execution halted          

I am using tidyverse, animation and other stuff. If I remove the functions that require them, then R Markdown works with CF.bib. That is, without specifying a path.


#10

Paul, this whole question would have been much easier with a reproducible example. I made one to show an example that works. The YAML is picky, so I made one. I also illustrated how to add an abstract and include a .csl file to format the bibliography. There is a github repo with all the formats linked in the example. I also added my favorite .css file. Hope this helps.

It is all on github here.