6

I am using the minted package, which requires option -shell-escape to be handed over to the processor. I use XeLateX as my processor. I updated AUCTeX using ELPA in emacs 24.3.1; AUCTeX is now version 11.88. According to this question, I can simply set the local variable TeX-command-extra-options to "-shell-escape". However, when I do this, and do C-c C-c (which is starting LaTeX), I still get the same error:

Package ifplatform Warning: 
    shell escape is disabled, so I can only detect \ifwindows.

))

! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.32 

What am I doing wrong? I've set the variable both by putting

%%% TeX-command-extra-options: "-shell-escape"

in my .tex source and by doing M-x set-variable by hand in the buffer. Both lead to the same result.

7
  • What's the value of LaTeX-command-style? Have you ever changed it?
    – giordano
    Nov 11, 2014 at 19:58
  • I've never edited it: LaTeX-command-style is a variable defined in tex.el'. Its value is (("" "%(PDF)%(latex) %(extraopts) %S%(PDFout)"))` Nov 11, 2014 at 21:31
  • Ok, the %(extraopts) expander is there. Then, after adding the file local setting of TeX-command-extra-options you should revert the buffer (M-x revert-buffer RET) or reset AUCTeX (C-c C-n), and you'll be asked whether TeX-command-extra-options is to be considered safe or not (it isn't safe by default because enabling shell escape is not safe), did you do such steps?
    – giordano
    Nov 12, 2014 at 0:08
  • I just tried both of these things (M-x revert-buffer RET) and resetting AUCTeX, but I was not asked whether TeX-command-extra-options is to be considered safe, and it still does not pass the extra options, as revealed in the first line of the output buffer, Running XeLaTeX' on proposal' with ``xelatex -interaction=nonstopmode "\input" proposal.tex'' Nov 12, 2014 at 0:37
  • I just tested with a fresh installation (without customizations) of AUCTeX from ELPA, it works as I described above. Try evaluating the following while in the buffer of the file with the TeX-command-extra-options: M-: (TeX-command-expand (nth 1 (assoc "LaTeX" TeX-command-list)) 'TeX-master-file) RET, what do you get? Note that the TeX-command-extra-options variable should be in all the file of the project.
    – giordano
    Nov 12, 2014 at 13:43

2 Answers 2

6

The handbook mentions in section 5.3 that you have to put local variables in a block such as this:

%%% Local Variables:
%%% TeX-command-extra-options: "-shell-escape"
%%% End:

PS.: It took me a while to figure it out as well. I think the documentation should introduce how local variables work (section 5.3) before giving configuration lines without the needed context (section 4.1.3).

1

Instead of inserting the %%% Local Variables ... %%%End: block each time, you are using the package minted, one should have a minted.el lisp package, which will be loaded by emacs and AUCTeX automatically in the instant, that you insert \usepackage{minted} in your files. (Or it will be loaded, whenever you load a file, which contains already the \usepackage{minted}).

AUCTeX comes with a wide variety of predefined .el supporting files. Unfortunately, there seems to be no file for the minted package. I attempted to write one myself and it seems to work (after a short and not thoroughly test).

In order, to just add the potential malicious option, whenever the minted-package is loaded, I added this code line:

(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape %S%(PDFout)")))

It is copied from this excellent article: Adding an option to the PDFLaTeX call from AUCTeX

I also asked emacs.SE for help, to polish up my somewhat dumb TeX-arg-minted-opts lisp function, in order to be able, to insert more than one option to a command or environment and even link them to the appropriate value expressions. In case, someone is interested: this is the question on Emacs.SE: https://emacs.stackexchange.com/questions/29617/auctex-and-package-minted

I intend to offer my lisp package to the AUCTeX, to be included in the main distribution. If anyone is interested in the package as is, please contact me or look it up at Emcas.SE.

1
  • This is really unsafe: shell escape makes it possible to run any command, included malicious ones. Users should be aware when using shell escape, if the editor enabled it automatically it would open a security hole.
    – giordano
    Dec 27, 2016 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .