use*_*089 5 yaml pandoc knitr r-markdown pandoc-citeproc
[仅供参考:这个问题与 rmarkdown 有关:如何为文档使用多个参考书目
在 LaTeX 文档甚至 Rmarkdown 中.Rnw,我可以简单地使用类似的东西
\bibliography{graphics, statistics, timeref}
Run Code Online (Sandbox Code Playgroud)
让 BibTeX
在我的本地目录下搜索文件graphics.bib、statistics.bib、 和。timeref.bibtexmf
在.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"
---
Run Code Online (Sandbox Code Playgroud)
问题:就像我可以r format(Sys.time(), '%d %B, %Y')使用 R 来填写日期一样,我可以使用一些 R 表达式来查找/填写 .bib 文件的路径吗bibliography:?
好的,从前面的问题来看,我尝试使用
bibliography:
- "`r system('kpsewhich graphics.bib')`"
- "`r system('kpsewhich statistics.bib')`"
- "`r system('kpsewhich timeref.bib')`"
Run Code Online (Sandbox Code Playgroud)
这会找到正确的路径,但只是将它们生成为 R markdown 日志中的输出,而不是生成到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
Run Code Online (Sandbox Code Playgroud)
我差点就猜对了,但是忘了intern=TRUE
这有效:
bibliography:
- "`r system('kpsewhich graphics.bib', intern=TRUE)`"
- "`r system('kpsewhich statistics.bib', intern=TRUE)`"
- "`r system('kpsewhich timeref.bib', intern=TRUE)`"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1126 次 |
| 最近记录: |