knitcitations gives pandoc-citeproc error

邮差的信 提交于 2020-01-12 08:01:09

问题


I have the following document, that I am trying to compile with Rstudio:

---
output: 
  word_document: 
    pandoc_args: [
      "--biblio", "references.bib"
    ]
---
```{r}
library("knitcitations")
cleanbib()
```
This is a citation citet("10.1098/rspb.2013.1372"): 
```{r}
citet("10.1098/rspb.2013.1372")
```

```{r}
write.bibtex(file="references.bib")
```

```{r}
summary(cars)
```

When I run knit, it compiles the .md file, but pandoc gives an error:

processing file: toy.Rmd
  |......................                                           |  33%
  ordinary text without R code

  |.............................                                    |  44%
label: unnamed-chunk-2
  |....................................                             |  56%
  ordinary text without R code

  |...........................................                      |  67%
label: unnamed-chunk-3
  |...................................................              |  78%
  ordinary text without R code

  |..........................................................       |  89%
label: unnamed-chunk-4
  |.................................................................| 100%
  ordinary text without R code


/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc toy.utf8.md --to docx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output toy.docx --highlight-style tango --biblio references.bib 
output file: toy.knit.md

pandoc: Error running filter pandoc-citeproc
pandoc-citeproc not found in path
Error: pandoc document conversion failed with error 83
Execution halted

The generated references file is references.bib:

@Article{Boettiger_2013,
  doi = {10.1098/rspb.2013.1372},
  url = {http://dx.doi.org/10.1098/rspb.2013.1372},
  year = {2013},
  month = {Jul},
  publisher = {The Royal Society},
  volume = {280},
  number = {1766},
  pages = {20131372-20131372},
  author = {C. Boettiger and A. Hastings},
  title = {No early warning signals for stochastic transitions: insights from large deviation theory},
  journal = {Proceedings of the Royal Society B: Biological Sciences},
}

回答1:


The error message is indicating that pandoc-citeproc is not found in your $PATH (i.e., /usr/bin/ etc.) One workaround is to create a link from pandoc-citeproc embedded in Rstudio and place it in the /usr/local/bin directory.

In the terminal:

sudo ln /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc-citeproc  /usr/local/bin/pandoc-citeproc
cd /usr/local/bin
chown root /usr/local/bin/pandoc-citeproc
chgrp wheel /usr/local/bin/pandoc-citeproc

pandoc result:



来源:https://stackoverflow.com/questions/25191744/knitcitations-gives-pandoc-citeproc-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!