YAML 标头中的 Latex shell-escape 选项不使用 [英] Latex shell-escape options in YAML header don't use
问题描述
我正在撰写关于 Rmarkdovn 的报告,但是当您尝试编译时 - 编译 pdf 时会忽略 pandoc_args 选项.
I'm writing a report on Rmarkdovn but when you try to compile - pandoc_args options ignored when compile pdf.
我发现这个问题:是否可以包含 svgrmarkdown 渲染的 pdf 文档中的图像?
但它不起作用,因为 --latex-engine-opt 被 --pdf-engine-opt 取代.我换了,也没用.
But it does not work because --latex-engine-opt replaced by --pdf-engine-opt. I replaced, but also did not work.
编译命令:
Rscript -e "rmarkdown::render('test.rmd')"
test.rmd
---
title: Test
papersize: a4paper
output:
pdf_document:
latex_engine: pdflatex
pandoc_args: [
--pdf-engine-opt, -shell-escape,
--pdf-engine-opt, -interaction=nonstopmode]
header-includes:
- \usepackage{minted}
---
输出:
processing file: test.rmd
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1 (with options)
List of 1
$ engine: chr "python"
output file: test.knit.md
/usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /home/renesat/R/x86_64-pc-linux-gnu-library/3.5/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --pdf-engine-opt --shell-escape --pdf-engine-opt -interaction=nonstopmode --variable 'geometry:margin=1in' --variable 'compact-title:yes'
! Package minted Error: You must invoke LaTeX with the -shell-escape flag.
Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted
我可以使用 knitr -> pandoc -> xelatex,但使用 YAML 头会更方便.
I can use knitr -> pandoc -> xelatex, but it would be more convenient to use YAML header.
推荐答案
R Markdown 文档通过 tinytex::latexmk()
编译为 PDF.要为您的 LaTeX 引擎启用 -shell-escape
选项,您可以设置全局选项 tinytex.engine_args
,例如,将此代码块添加到您的文档中:
R Markdown documents are compiled to PDF via tinytex::latexmk()
. To enable the -shell-escape
option for your LaTeX engine, you may set the global option tinytex.engine_args
, e.g., add this code chunk to your document:
```{r, include=FALSE}
options(tinytex.engine_args = '-shell-escape')
```
查看帮助页面 ?tinytex::latexmk
了解更多信息.
See the help page ?tinytex::latexmk
for more information.
LaTeX 引擎由 tinytex::latexmk()
而不是 Pandoc 调用,因此 Pandoc 参数 --pdf-engine-opt
将不起作用.
The LaTeX engine is called by tinytex::latexmk()
instead of Pandoc, so the Pandoc argument --pdf-engine-opt
won't work.
这篇关于YAML 标头中的 Latex shell-escape 选项不使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!