Emacs preview-latex minted package and -shell-escape
Asked Answered
M

1

8

I'm trying to use emacs with preview-latex (C-c C-p C-b) to view my document. First a minimal example of my document:

\documentclass {article}
\usepackage{minted}
\begin{document}
\begin{listing}[H]
\begin{minted}{sql}
  Select * from FOOBAR;
\end{minted}
\caption{Test Query}
\label{code:query}
\end{listing}
\end{document}

I already tried using Using minted (source code LaTeX package) with emacs/auctex the following answer but it does not seem to work with preview-latex.

I get the following error message:

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

So I changed my latex-mode-hook to the following:

(defun kungi/latex-mode-hook ()
  (turn-on-flyspell)
  (auto-complete-mode 1)
  (turn-on-reftex)
  (turn-on-auto-fill-mode)
  (push
   '("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
     :help "Run Latexmk on file")
   TeX-command-list)

(eval-after-load "tex"
  '(setcdr (assoc "LaTeX" TeX-command-list)
          '("xelatex -shell-escape %t"
          TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")))


(add-hook 'LaTeX-mode-hook
          'kungi/latex-mode-hook)

Can you please tell me what I am doing wrong? Is it possible to use minted with preview latex?

Modern answered 11/1, 2012 at 20:54 Comment(0)
M
3

I am using VIM with the LaTeX_Box plugin and I ran into a similar issue getting the very same error message. I could solve it by simply putting a file with the following contents to ~/.latexmkrc

$latex = 'latex --shell-escape';
$pdflatex = 'pdflatex --shell-escape';
Maddi answered 3/4, 2012 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.