简体   繁体   English

使用minted(源代码LaTeX包)和emacs / auctex

[英]Using minted (source code LaTeX package) with emacs/auctex

As is explained in here , I find minted package is pretty cool for source code listing. 正如这里所解释的,我发现minted包对于源代码列表非常酷。

My question is how to use minted package with AucTeX/emacs? 我的问题是如何使用AucTeX / emacs的铸造包? For command line I can use pdflatex -shell-escape SOURCE , but 对于命令行,我可以使用pdflatex -shell-escape SOURCE ,但是

  • Q1 : How can I modify the AucTeX to insert the -shell-escape ? Q1:如何修改AucTeX以插入-shell-escape I mean, how to change the action for C - c + C - c ? 我的意思是,如何改变C - c + C - c的动作
  • Q2 : Do I need special key other than C - c + C - c for -shell-escape option? Q2:除了C - c + C - c还需要-shell-escape选项以外的特殊键吗? Or, is it just OK to use it without any problem? 或者,可以毫无问题地使用它吗?
  • Q3 : What is the -shell-escape for? 问题3:什么是-shell-escape

Q1: You need to edit the way LaTeX is called by AucTeX. Q1:您需要编辑AucTeX调用LaTeX的方式。 One way of doing this is to add the following to your .emacs file: 一种方法是将以下内容添加到.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")
    )
  )

Q2: Once you have made the changes, all calls to LaTeX with Cc Cc will use the -shell-escape option. Q2:完成更改后,使用Cc Cc对LaTeX的所有调用都将使用-shell-escape选项。

Q3: See Konrad's answer. Q3:见康拉德的回答。 Note that this method will enable -shell-escape for all files edited in AucTeX, so can be a potential security risk if using other peoples packages or files. 请注意,此方法将为-shell-escape编辑的所有文件启用-shell-escape ,因此如果使用其他人包或文件,则可能存在潜在的安全风险。

I can only answer question 3: 我只能回答问题3:

What is the '-shell-escape' for? 什么是'-shell-escape'?

minted uses a third-party application, pygmentize , to process the source code. minted使用第三方应用程序pygmentize来处理源代码。 LaTeX usually doesn't allow calling other applications for security reasons (a rogue package could otherwise call aribtrary code). 由于安全原因,LaTeX通常不允许调用其他应用程序(否则流氓包可能会调用aribtrary代码)。 To explicitly enable calling external applications, you need to enable this so-called escape to the shell – which, on most LaTeX installations, is done via the -shell-escape switch. 要显式启用调用外部应用程序,您需要启用这个所谓的转义到shell - 在大多数LaTeX安装中,通过-shell-escape开关完成。

In recent versions of auctex, it looks like it'll be more reliable to set TeX-command-extra-options , which is designed for just this purpose, and doesn't make you override the various forms of TeX-command . 在auctex的最新版本中,看起来设置TeX-command-extra-options (仅用于此目的)会更加可靠,并且不会使您覆盖各种形式的TeX-command As I understand it (might be wrong), this can't be set globally, but must be set for each file. 据我所知(可能是错误的),这不能全局设置,但必须为每个文件设置。 You can do this with a hook. 你可以用钩子做到这一点。 For example, in .emacs you might add this: 例如,在.emacs您可以添加以下内容:

(add-hook 'TeX-mode-hook
  (lambda ()
    (setq TeX-command-extra-options "-shell-escape")
  )
)

And since you don't fully overwrite the latex command call, other features will still work -- like turning on synctex support with (setq TeX-source-correlate-mode t) [which can happen outside the hook]. 而且由于你没有完全覆盖latex命令调用,其他功能仍然可以工作 - 比如启用synctex支持(setq TeX-source-correlate-mode t) [这可能发生在钩子之外]。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM