Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

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.