I want to render an Rmarkdown file that requires the -shell-escape
option in pdflatex or --pdf-engine-opt=-shell-escape
option in pandoc. I specified pandoc_args: "--pdf-engine-opt=-shell-escape"
in my YAML header, but rmarkdown::render() seems to call programs in this order:
- knitr::knit() to *.md
- encoding conversion to *.utf8.md
- pandoc to *.tex (
pandoc mwe.utf8.md --to latex --output mwe.tex ...
) - pdflatex to *.pdf (
pdflatex mwe.tex
)
render() loses my -shell-escape
option between steps 3 and 4, and I get an error since pdflatex cannot pass a command to the shell. Is there a way to either: 1) have pandoc output a *.pdf file instead of *.tex, or 2) pass -shell-escape
onto pdflatex?
MWE: mwe.Rmd
---
title: "mwe"
header-includes: |
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.tif}{png}{.png}{sips -s format png #1 --out \OutputFile}
\PrependGraphicsExtensions{.tif, .tiff}
output:
pdf_document:
pandoc_args: "--pdf-engine-opt=-shell-escape"
---
![](image.tif)
Running $ rmarkdown::render("mwe.Rmd", output_file="mwe.pdf")
in R console gives the error since pdflatex was not called with -shell-escape
:
! Package pdftex.def Error: File `image-tif-converted-to.png' not found.
Error: Failed to compile mwe.tex. See mwe.log for more info.
Running $ knitr::knit("mwe.Rmd")
in R console followed by $ pandoc mwe.md -o mwe.pdf
in the terminal returns the correct PDF. Alternatively, running $ pandoc mwe.md -s -o mwe.tex; pdflatex -shell-escape mwe.tex
on the intermediate tex file in the terminal also returns the correct PDF.
TIF image obtained from: https://upload.wikimedia.org/wikipedia/commons/6/6a/Chi_Recombination_Model_for_Wikipedia.tif