[FYI: This question is related to rmarkdown: how to use multiple bibliographies for a document
In LaTeX documemnts or even in Rmarkdown .Rnw
, I can simply use something like
\bibliography{graphics, statistics, timeref}
to have BibTeX search for the files graphics.bib
, statistics.bib
, and timeref.bib
under my local texmf
directories.
In a .Rmd
file, using a yaml
header, I'm forced to list each bibliography file using either
absolute paths (not portable), or relative paths (clunky, error-prone). Here is one recent example:
---
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"
---
Question: Just as I can use r format(Sys.time(), '%d %B, %Y')
to use R to fill in the date, can I use some R expression to find/fill-in the paths to my .bib files under bibliography:
?
OK, from the earlier question, I tried using
bibliography:
- "`r system('kpsewhich graphics.bib')`"
- "`r system('kpsewhich statistics.bib')`"
- "`r system('kpsewhich timeref.bib')`"
This finds the correct paths, but just generates them as output in the R markdown log, rather than into the yaml
header. I see:
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