TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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!

share|improve this answer
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 '12 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")))
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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