I am wondering if there is any way to have one bibliography per chapter (possibly with a global bibliography at the very end) when the citations are handled by pandoc rather than biblatex? I am only rendering to PDF format.
This should be a reproducible example for the lua error I'm running into (section-refs.lua can be found here):
# (index.Rmd)
---
output:
pdf_document:
pandoc_args:
- --lua-filter=section-refs.lua
section-refs-bibliography: refs.bib
---
# Chapter 1
This is some text [@ainsworth:sheppard].
# Chapter 2
This is some text [@altick:aldine].
# (refs.bib)
@BOOK{ainsworth:sheppard,
title = {Jack Sheppard: A Romance},
author = {William Harrison Ainsworth},
address = {London},
publisher = {George Routledge \& Sons},
year = {1900},
shorttitle = {Jack Sheppard},
}
@Article{altick:aldine,
author = {Richard D. Altick},
title = {From Aldine to Everyman: Cheap Reprint Series of the
English Classics 1830--1906},
journal = {Studies in Bibliography},
year = 1958,
volume = 11,
pages = {3--24}
}
This is the error when trying to render index.Rmd.
Unknown option --citeproc.
Try pandoc --help for more information.
Error running filter section-refs.lua:
PandocFilterError "pandoc" "Filter returned error status 6"
stack traceback:
[C]: in function 'pandoc.utils.run_json_filter'
section-refs.lua:58: in upvalue 'run_citeproc'
section-refs.lua:88: in function <section-refs.lua:66>
Error: pandoc document conversion failed with error 83
Execution halted
Really stuck and hoping someone with knowledge of lua could maybe save the save (@cderv, @rlesur)??
For what its worth, if I knit index.Rmd first with knitr::knit('index.Rmd', 'index.md') and then run pandoc via pandoc index.md --lua-filter section-refs.lua -o index.pdf it works.
It seems you already opened an issue in Pandoc regarding the usage of the filter:
You need to check that you get the expected Pandoc version compatible with the filter - or download the correct filter.
Also, it is possible that there is an order in which the filter should be run and that it is not compatible currently with rmarkdown::pdf_document() .
Specifically the filter seems to run citeproc so maybe it shouldn't be run by rmarkdown dans you should deactivate running pandoc citeproc - I think you can deactivate adding this in your yaml header
citeproc: false
Anyway, R Markdown output formats are wrapper around ways of running knitr + pandoc, and they are designed for the most generic usage to help user do this without much knowledge of Pandoc. so it is possible that it is not compatible with advanced usage of Pandoc directly.
Maybe doing what you want with the specific filter requires a new custom output format to correctly adjust the call to Pandoc.
Let's see where the GH issue leads in case there is something wrong in the filter.
Thanks for the response, @cderv. I did end up creating an issue over there once I discovered that filter (which was not the original motivation for this post).
Turns out it indeed was a version issue based on the version included in the RStudio Daily build and the version I had installed from brew. Fixing this worked and I can use this filter with R markdown without issue.