rmarkdown:如何对一个文档使用多个参考书目 [英] rmarkdown: how to use multiple bibliographies for a document
问题描述
[我的环境:Win 7 Pro/R 3.2.1/knitr_1.12.3/R Studio版本0.99.892]
[My environment: Win 7 Pro / R 3.2.1 / knitr_1.12.3 / R Studio Version 0.99.892]
我正在尝试使用R Studio,Knit-> PDF以.Rmd
格式撰写文章,并且一直在关注 http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html 了解有关如何获取pandoc
和pandoc-citeproc
来生成参考"部分和引文的详细信息
在文本中.
I am trying to write an article in .Rmd
format using R Studio, Knit -> PDF, and I've been following http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html for details of how to get pandoc
and pandoc-citeproc
to produce a References section and citations
in the text.
我的BibTeX引用位于几个不同的.bib
文件中,使用时
.Rnw
文件中的LaTeX均可通过
在我的本地texmf树中找到
My BibTeX references are in several different .bib
files, which, when using
LaTeX in .Rnw
files, are all found in my local texmf tree via
\bibliography{statistics, graphics}
我似乎无法使用pandoc-citeproc
进行此操作.我的YAML标头
具有以下内容,只要它适用于一个 .bib
文件
与源.Rmd
文件位于同一目录中:
I can't seem to make this work with pandoc-citeproc
. My YAML header
has the following, that works for one .bib
file, as long as it is
in the same directory as the source .Rmd
file:
---
title: "Notes on Testing Equality of Covariance Matrices"
author: "Michael Friendly"
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
csl: apa.csl
bibliography: statistics.bib
---
按照上面给出的链接中的建议,我尝试了:
Following advice in the link given above, I tried:
bibliography: [statistics.bib,graphics.bib]
这给出了:
pandoc-citeproc.exe: "stdin" (line 50, column 12):
unexpected ":"
expecting letter, digit, white space or "="
pandoc.exe: Error running filter pandoc-citeproc
Filter returned error status 1
:
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS EqCov.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output EqCov.pdf --template "C:\R\R-3.2.1\library\rmarkdown\rmd\latex\default-1.15.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --bibliography statistics.bib --bibliography graphics.bib --filter pandoc-citeproc
output file: EqCov.knit.md
以下所有形式也是如此:
So do all the following forms:
bibliography: ["statistics.bib","graphics.bib"]
bibliography:
- "statistics.bib"
- "graphics.bib"
bibliography:
- statistics.bib
- graphics.bib
理想情况下,我希望能够使用以下形式之一,而不必将.bib文件复制到文档目录中.
Ideally, I'd like to be able to use one of the following forms, and not have to copy the .bib files to the document directory.
bibliography: ["C:/Dropbox/localtexmf/bibtex/bib/statistics.bib","C:/Dropbox/localtexmf/bibtex/bib/graphics.bib"]
bibliography:
- "C:/Dropbox/localtexmf/bibtex/bib/statistics.bib"
- "C:/Dropbox/localtexmf/bibtex/bib/graphics.bib"
推荐答案
记录如下:我在事实证明,在pandoc-citeproc
如何处理@{string={}}
中的某些字符和.bib
文件中的非ASCII字符方面存在问题,因此我现在尝试的方法是在所有路径中使用硬编码路径名我尝试过的表格.
It turns out that there were problems in how pandoc-citeproc
handles some characters in @{string={}}
and non-ASCII characters in .bib
files, so what I was trying now works, with hard-coded pathnames, in all the forms I tried.
要使其更像通过Latex/bibtex处理.Rnw
文件,能够使用类似的东西
To make it work more like processing of .Rnw
files via Latex/bibtex it would be nice to be able to use something like
bibliography:
- `r system(kpsewhich statistics.bib)`
- `r system(kpsewhich graphics.bib)`
这些命令 do 在R会话中找到正确的文件,但不是从YAML标头中找到.
Those commands do find the right files in an R session, but not from a YAML header.
这篇关于rmarkdown:如何对一个文档使用多个参考书目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!