【发布时间】:2020-08-10 07:53:00
【问题描述】:
[仅供参考:这个问题与rmarkdown: how to use multiple bibliographies for a document有关
在 LaTeX 文档甚至 Rmarkdown .Rnw 中,我可以简单地使用类似
\bibliography{graphics, statistics, timeref}
让 BibTeX 搜索文件 graphics.bib、statistics.bib 和 timeref.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 表达式来查找/填写@ 下的.bib 文件的路径987654333@?
好的,从前面的问题中,我尝试使用
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
【问题讨论】:
-
有趣的问题!你看过this的帖子吗?
-
是的,我看过那篇文章,但它(不是真的)回答了一个不同的问题。这个问题和类似问题暴露了
yaml-> {r-markdown,pandoc-citeproc} 链中的缺陷/限制。我发布这个是因为我认为对于我描述的特定问题可能有一个聪明的解决方法。
标签: yaml r-markdown knitr pandoc pandoc-citeproc