This is a follow-up to knitr/Rmarkdown/pandoc : How to set bibliography paths globally in .Rmd files where a solution that works with knitr/rmarkdown/pandoc
does NOT work with Quarto.
I have multiple .bib
files in a system-wide localtexmf
folder. I want to specify that some of these are searched for references in a quarto document. (I don't want to have to copy each of these to the project folder or specify full absolute or relative paths to these files.)
With knitr/rmarkdown/pandoc
I can use:
bibliography:
- references.bib
- "`r system('kpsewhich graphics.bib', intern=TRUE)`"
- "`r system('kpsewhich statistics.bib', intern=TRUE)`"
- "`r system('kpsewhich timeref.bib', intern=TRUE)`"
However, using Quarto, this gives an error:
Preparing to preview
[1/2] intro.qmd
File r system('kpsewhich graphics.bib', intern=TRUE) not found in resource path
The system(kpsewhich())
command does find the files in the console:
> system('kpsewhich graphics.bib')
C:/Users/friendly/Dropbox/localtexmf/bibtex/bib/graphics.bib
[1] 0
How can I make this work using Quarto? Is there something different with the YAML syntax for Quarto? Is there some other way?
Edit:
This may be a more general problem of using r function()
in YAML with Quarto. This attempt to set the date:
doesn't give an error, but yields
Invalid date in the rendered book.
date: "`r format(Sys.time(), '%B %d, %Y')`"
[This is now solved, using !expr format(Sys.time(), '%B %d, %Y')
as suggested by @shafee.
Testing PDF:
Rendering to PDF gives more clues about why even the !expr
solution doesn't work with Quarto. In the console, I get:
bibliography:
- references.bib
- tag: '!expr'
value: system('kpsewhich graphics.bib'
- intern=TRUE)
- tag: '!expr'
value: system('kpsewhich statistics.bib'
- tag: '!expr'
value: system('kpsewhich timeref.bib'
date:
tag: '!expr'
value: 'format(Sys.time(), ''%B %d, %Y'')'
File intern=TRUE) not found in resource path
so Quarto seems to have trouble parsing the system()
call with the intern=TRUE
option. This seems like a bug.