Latex shell-escape options in YAML header don't use

被刻印的时光 ゝ 提交于 2020-07-22 21:40:38

问题


I'm writing a report on Rmarkdovn but when you try to compile - pandoc_args options ignored when compile pdf.

I find this question: Is it possible to include svg image in pdf document rendered by rmarkdown?

But it does not work because --latex-engine-opt replaced by --pdf-engine-opt. I replaced, but also did not work.

Compilation command:

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}
---

Output:

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

I can use knitr -> pandoc -> xelatex, but it would be more convenient to use YAML header.


回答1:


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')
```

See the help page ?tinytex::latexmk for more information.

The LaTeX engine is called by tinytex::latexmk() instead of Pandoc, so the Pandoc argument --pdf-engine-opt won't work.



来源:https://stackoverflow.com/questions/55459948/latex-shell-escape-options-in-yaml-header-dont-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!