使用 pandoc 启用 shell 转义

HSc*_*ale 4 latex graphviz pandoc

我正在尝试在 pandoc 降价文档中使用 latex graphvis 包。然而,它似乎需要将-shell-escape标志传递给乳胶。如何-shell-escape在 pandoc 上启用?

\digraph[scale=0.5]{MyGraph}{
Business -- Job;
Job -- Task;
Job -- User;
Job -- PayRate;
Task -- WorkSession;
User -- WorkSession;
PayRate -- WorkSession;
}
Run Code Online (Sandbox Code Playgroud)

http://mark.aufflick.com/blog/2007/03/25/embedding-graphviz-in-latex-documents

小智 6

pandoc现在可以通过--latex-engine-opt标志直接将参数传递给 LaTeX 引擎。例如,为了将-shell-escape标志传递给xelatex您,您可以执行以下操作:

pandoc myfile.md -s -o myfile.pdf --latex-engine=xelatex --latex-engine-opt=-shell-escape
Run Code Online (Sandbox Code Playgroud)

  • 您应该更新您的答案:最新版本的 pandoc 告诉 `--latex-engine-opt 已被删除。使用 --pdf-engine-opt 代替。`。 (2认同)

Gil*_*il' 2

您可以告诉 pandoc 生成 LaTeX,然后对输出执行任何您想要的操作。

pandoc -o mydocument.tex mydocument.md
pdflatex -shell-escape mydocument.tex
Run Code Online (Sandbox Code Playgroud)

Pandoc 有一个选项告诉它以不同的方式运行 LaTeX,但这只能是名为,或 的--latex-engine程序的路径。如果由于某种原因您希望能够通过直接调用从 Markdown 生成 PDF,您可以使用包装脚本。pdflatexlualatexxelatexpandoc

pandoc --latex-engine=/path/to/pdflatex -o mydocument.pdf mydocument.md
Run Code Online (Sandbox Code Playgroud)

其中/path/to/pdflatex可执行并包含(假设是类 Unix 系统)

#!/bin/sh
exec pdflatex -shell-escape "$@"
Run Code Online (Sandbox Code Playgroud)