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.

  • What's the value of LaTeX-command-style? Have you ever changed it? – giordano Nov 11 '14 at 19:58
  • I've never edited it: LaTeX-command-style is a variable defined intex.el'. Its value is (("" "%(PDF)%(latex) %(extraopts) %S%(PDFout)"))` – user2108497 Nov 11 '14 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 '14 at 00: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, RunningXeLaTeX' on proposal' with ``xelatex -interaction=nonstopmode "\input" proposal.tex'' – user2108497 Nov 12 '14 at 00: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 '14 at 13:43
  • There is only one file in the project (well, there are figures, but only one tex file). That command returns "pdflatex -interaction=nonstopmode \"\\input\" proposal.tex" Thank you for all of your help so far! – user2108497 Nov 12 '14 at 18:05
  • I tried again on another computer, same result: works for me out of the box (except for making TeX-command-extra-options safe). I'm trying to figure out what's wrong with your system. These are the last tests I can think of: in the LaTeX buffer issue M-: (apply (cadr (assoc "%l" TeX-expand-list)) nil) RET, this should return the value of LaTeX-command-style. If so, check the value of TeX-expand-list, there should be a ("%(extraopts)" (lambda nil TeX-command-extra-options)) entry. Then check the value of TeX-command-extra-options in that buffer, it should be "-shell-escape". – giordano Nov 12 '14 at 21:53

2 Answers2

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).

dubadu
  • 161
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.

Jan
  • 5,293
  • 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 '16 at 21:04