I need preview-latex to use the -shell-escape option when it invokes PDFLaTeX, which is required by the minted package for syntax highlighting, as it invokes python. How can I do that?


2 Answers 2


From the preview-latex documentation :


When you generate previews on a buffer or a region, the command in preview-LaTeX-command gets run (that variable should only be changed with Customize since its structure is somewhat peculiar, though expressive). As usual with AUCTeX, you can continue working while this is going on. It is not a good idea to change the file until after preview-latex has established where to place the previews which it can only do after the LaTeX run completes. This run produces a host of pseudo-error messages that get parsed by preview-latex at the end of the LaTeX run and give it the necessary information about where in the source file the LaTeX code for the various previews is located exactly. The parsing takes a moment and will render Emacs busy.

Browse the AUCTeX customize-group to >Preview > Preview Latex and find the option Preview latex command. Unfolded, it looks this way :

enter image description here

Replacing the line

%`%l "\nonstopmode\nofiles\PassOptionsToPackage{


%`%l -shell-escape "\nonstopmode\nofiles\PassOptionsToPackage{

should do the trick. Don't forget to click "Set for current session", and "Save for future sessions" if it works!

  • awesome, that works. Actually, I was already looking at customizing this variable preview-LaTeX-command, but wasn't sure where in all these strings to add the option, so I figured it would be nice to ask, so someone else with the same problem could find a solution quicker than me :)
    – sebastian
    Dec 2, 2012 at 23:14

Based on the previous answer, I changed the settings through the UI, and looked at what was being written out to .emacs - the parts that are pertinent for this question are

 '(preview-LaTeX-command (quote ("%`%l -shell-escape \"\\nonstopmode\\nofiles\\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined" preview-default-preamble "\\fi}\"%' %t")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.