【发布时间】:2016-10-30 21:05:09
【问题描述】:
我正在尝试在 Markdown 文件中使用自定义引用样式,但每次编织时引用都使用默认(芝加哥)样式。我尝试将输出格式从 JS 显示演示文稿更改为 HTML 文档到 PDF 文档,但它仍然不起作用。我正在使用 knitcitations 包来引用文档的 DOI,并使用 bibliography() 函数来编写参考书目。我也尝试过使用 Zotero 上的 apa.csl 样式,但引用仍以默认样式完成。 apa.csl 文件与我尝试在其中使用引文的文件存储在同一文件夹中,newbiblio.bib 文件也是如此,我在其中存储了我要引用的项目的书目信息。
以下是我的降价代码:
---
title: "htmlcitetest"
citation_package: natbib
csl: "apa.csl"
output:
pdf_document:
pandoc_args: ["--natbib"]
biblio-style: unsrt
bibliography: newbiblio.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(bibtex)
library(knitcitations)
options("citation_format" = "pandoc")
library(RefManageR)
cleanbib()
```
## R Markdown
- This is a citation [^1]
[^1]: `r citet("10.1098/rspb.2013.1372")`
```{r, message=FALSE}
bibliography()
```
此链接 (http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html) 说我应该能够像这样格式化我的 YAML 标头:
---
title: "Sample Document"
output: html_document
bibliography: newbiblio.bib
csl: apa.csl
---
但是,当我这样做时,文件会合并到一个降价 (.md) 文件,但它不会被处理到输出中。我收到此错误:
pandoc-citeproc: 23:3-23:10: Expected end element for: Name {nameLocalName = "category", nameNamespace = Just "http://purl.org/net/xbiblio/csl", namePrefix = Nothing}, but received: EventEndElement (Name {nameLocalName = "info", nameNamespace = Just "http://purl.org/net/xbiblio/csl", namePrefix = Nothing})
pandoc: Error running filter /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc-citeproc
Filter returned error status 1
Error: pandoc document conversion failed with error 83
Execution halted
我的 .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},
}
我也不明白为什么 YAML 标头中的 biblio-style 选项没有做任何事情。从本质上讲,我所需要的只是一种使用我已经用 Markdown 文档制作的自定义引用样式的方法。任何帮助将不胜感激!
【问题讨论】:
-
当您收到来自
pandoc-citeproc的错误时,您似乎走在了正确的道路上。但是错误提示它无法解析您的 .csl 文件...要么它不是有效的 csl 文件(尝试validating it),要么pandoc-citeproc 有问题... -
我可以帮助您知道,当您在围兜参考中有多个作者时,他们必须用“and”分隔(不是“AND”,大小写对 YAML 很重要,而在乳胶中无关紧要)。
标签: yaml knitr r-markdown pandoc citations