pro*_*eek 11 emacs latex auctex
As is explained in here, I find minted package is pretty cool for source code listing.
My question is how to use minted package with AucTeX/emacs?
For command line I can use pdflatex -shell-escape SOURCE, but
-shell-escape? I mean, how to change the action for C-c+C-c?-shell-escape选择吗?或者,可以毫无问题地使用它吗?-shell-escape用?Sim*_*rne 15
Q1:您需要编辑AucTeX调用LaTeX的方式.一种方法是将以下内容添加到.emacs文件中:
(eval-after-load "tex"
'(setcdr (assoc "LaTeX" TeX-command-list)
'("%`%l%(mode) -shell-escape%' %t"
TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")
)
)
Run Code Online (Sandbox Code Playgroud)
Q2:完成更改后,所有使用Cc Cc调用LaTeX都将使用该-shell-escape选项.
Q3:见康拉德的回答.请注意,此方法将启用-shell-escape在AucTeX中编辑的所有文件,因此如果使用其他人包或文件,则可能存在潜在的安全风险.
我只能回答问题3:
什么是'-shell-escape'?
minted使用第三方应用程序pygmentize来处理源代码.由于安全原因,LaTeX通常不允许调用其他应用程序(否则流氓包可能会调用aribtrary代码).要显式启用调用外部应用程序,您需要启用这个所谓的转义到shell - 在大多数LaTeX安装中,通过-shell-escape交换机完成.
在auctex的最新版本中,看起来设置更加可靠TeX-command-extra-options,这是为了这个目的而设计的,并不会让你覆盖各种形式的TeX-command.据我所知(可能是错误的),这不能全局设置,但必须为每个文件设置.你可以用钩子做到这一点.例如,.emacs您可以添加以下内容:
(add-hook 'TeX-mode-hook
(lambda ()
(setq TeX-command-extra-options "-shell-escape")
)
)
Run Code Online (Sandbox Code Playgroud)
而且由于你没有完全覆盖latex命令调用,其他功能仍然可以工作 - 比如打开synctex支持(setq TeX-source-correlate-mode t)[可能发生在钩子之外].