2

I'm using the R package knitr to generate a markdown file test.md. This file is then processed by pandoc to produce a variety of output formats, such as html and pdf. Because I want to use bibtex when generating the pdf through latex, I believe I have to tell pandoc to stop at the intermediate latex output, and then run bibtex and pdflatex myself (twice). Here's where I found a slight annoyance in my workflow: the only way I found for pandoc to keep the intermediate tex file, and not go all the way to the pdf, was to specify a hard-coded filename through the -o option with a .tex extension. This is problematic for me because I'm using a config file to run pandoc('test.md', "latex", "config.pandoc") via knitr with options, which I would like to keep generic without hard-coded output filename:

format: latex
o: test.tex
s: 
S:
biblio: refs.bib
biblatex:
template: 'template.tex'
default-image-extension: pdf

which in turn becomes the following command for pandoc,

pandoc -s -S --biblio=refs.bib --default-image-extension=pdf --biblatex --template='template.tex'  -f markdown -t latex -o test.tex 'test.md'

If I skip the o: test.tex option, pandoc produces a pdf and doesn't keep the intermediate latex file. How can I keep the tex file, without specifying this hard-coded filename?

4

1 回答 1

2

为了解决我这边的这个问题,我extpandoc()函数中添加了一个新参数。它现在在 Github上可用(knitr 开发版本 1.3.6)。您可以覆盖默认文件扩展名,例如

library(knitr)
pandoc(..., ext = 'tex')
于 2013-07-31T09:11:03.000 回答