我想渲染一个Rmarkdown文件,该文件需要pdflatex中的-shell-escape
选项或pandoc中的--pdf-engine-opt=-shell-escape
选项。我在YAML标头中指定了pandoc_args: "--pdf-engine-opt=-shell-escape"
,但rmarkdown :: render()似乎按以下顺序调用程序:
pandoc mwe.utf8.md --to latex --output mwe.tex ...
)pdflatex mwe.tex
)render()在第3步和第4步之间丢失了我的-shell-escape
选项,并且由于pdflatex无法将命令传递到外壳程序而导致错误。有没有办法:1)使pandoc输出* .pdf文件而不是* .tex,或2)将-shell-escape
传递到pdflatex?
---
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)
由于未使用$ rmarkdown::render("mwe.Rmd", output_file="mwe.pdf")
调用pdflatex,因此在R控制台中运行-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.
$ knitr::knit("mwe.Rmd")和终端中的$ pandoc mwe.md -o mwe.pdf
,将返回正确的PDF。或者,在终端的中间tex文件中运行$ pandoc mwe.md -s -o mwe.tex; pdflatex -shell-escape mwe.tex
也会返回正确的PDF。
从:https://upload.wikimedia.org/wikipedia/commons/6/6a/Chi_Recombination_Model_for_Wikipedia.tif获得的TIF图像
我想渲染一个Rmarkdown文件,该文件需要pdflatex中的-shell-escape选项或pandoc中的--pdf-engine-opt = -shell-escape选项。我在...