knitr / Rmarkdown / pandoc:如何在.Rmd文件中全局设置书目路径

问题描述 投票:0回答:1

[FYI:此问题与rmarkdown: how to use multiple bibliographies for a document

在LaTeX文档中,甚至在Rmarkdown .Rnw中,我都可以使用类似的东西

\bibliography{graphics, statistics, timeref}

使BibTeX搜索文件graphics.bibstatistics.bibtimeref.bib在我的本地texmf目录下。

.Rmd文件中,使用yaml标头,我被迫使用以下任一方法列出每个书目文件绝对路径(不可移植)或相对路径(笨重,容易出错)。这是最近的一个例子:

---
title: "My Cool Paper"
author: "Me"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  html_document

bibliography:
  - "../../../localtexmf/bibtex/bib/graphics.bib"
  - "../../../localtexmf/bibtex/bib/statistics.bib"
  - "../../../localtexmf/bibtex/bib/timeref.bib"
---

问题:就像我可以使用r format(Sys.time(), '%d %B, %Y')使用R来填写日期一样,我可以使用一些R表达式来查找/填写bibliography:下我的.bib文件的路径吗?] >

确定,从前面的问题开始,我尝试使用

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

这会找到正确的路径,但只是将它们生成为R降价日志中的输出,而不是生成为yaml标头中的路径。我看到:

processing file: Vis-MLM.Rmd
  |........                                                              |  11%
   inline R code fragments

C:/Users/friendly/Dropbox/localtexmf/bibtex/bib/graphics.bib
C:/Users/friendly/Dropbox/localtexmf/bibtex/bib/statistics.bib
C:/Users/friendly/Dropbox/localtexmf/bibtex/bib/timeref.bib
[

我几乎是对的,但是忘记了intern=TRUE
此作品:

bibliography: - "`r system('kpsewhich graphics.bib', intern=TRUE)`" - "`r system('kpsewhich statistics.bib', intern=TRUE)`" - "`r system('kpsewhich timeref.bib', intern=TRUE)`"

yaml r-markdown knitr pandoc pandoc-citeproc
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.