【问题标题】:rmarkdown: how to use multiple bibliographies for a documentrmarkdown:如何为一个文档使用多个参考书目
【发布时间】:2016-07-12 03:38:45
【问题描述】:

[我的环境: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 以获取有关如何获取 pandocpandoc-citeproc 以生成参考的详细信息部分和引文 在正文中。

我的 BibTeX 参考文献在几个不同的 .bib 文件中,当使用 .Rnw 文件中的 LaTeX 都可以在 我的本地 texmf 树 通过

找到
\bibliography{statistics, graphics}

我似乎无法使用pandoc-citeproc 完成这项工作。我的 YAML 标头 具有以下内容,适用于 one .bib 文件,只要它是 在与源.Rmd 文件相同的目录中:

    ---
    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
    ---

按照上面给出的链接中的建议,我尝试了:

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

[编辑:为了完整起见,我展示了生成的pandoc 命令,看起来两个 .bib 文件都正确传递了]:

"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

以下所有形式也是如此:

    bibliography: ["statistics.bib","graphics.bib"]

    bibliography: 
      - "statistics.bib"
      - "graphics.bib"

    bibliography: 
      - statistics.bib
      - graphics.bib

理想情况下,我希望能够使用以下形式之一,而不必将 .bib 文件复制到文档目录。

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"

【问题讨论】:

  • 请注意 - 这似乎在 HTML 输出中没有问题。 pdf问题有更新吗?

标签: r rstudio knitr r-markdown pandoc


【解决方案1】:

郑重声明:我在https://github.com/jgm/pandoc-citeproc/issues/220https://github.com/jgm/pandoc-citeproc/issues/220@pandoc-citeproc 上提出了这个问题

事实证明,pandoc-citeproc 如何处理 @{string={}} 中的某些字符和 .bib 文件中的非 ASCII 字符存在问题,所以我现在尝试的方法是使用硬编码的路径名,在所有我试过的形式。

为了让它更像是通过 Latex/bibtex 处理 .Rnw 文件,能够使用类似的东西会很好

bibliography: 
  - `r system(kpsewhich statistics.bib)`
  - `r system(kpsewhich graphics.bib)`

这些命令 do 在 R 会话中找到正确的文件,但不是从 YAML 标头中找到。

【讨论】:

  • 我发现 R 命令可以(有时)通过将 YAML 标头封装在单引号中来运行,因此以下可能有效:- '`r system(kpsewhich statistics.bib)`' 例如,这适用于 YAML “日期”标题:date: '`r format(Sys.Date(), "%B %Y")`'
猜你喜欢
  • 2016-01-01
  • 1970-01-01
  • 2021-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-22
相关资源
最近更新 更多