0

I want to use minted package in my tex file. It needs the command-line option --shell-escape to allow external pygmentize program execution. How can I add that option to the tex engine?

My related code snippets are

(add-hook 'LaTeX-mode-hook
        (lambda ()
          (setq TeX-auto-untabify t     ; remove all tabs before saving
                TeX-engine 'xetex       ; use xelatex default
                TeX-show-compilation t) ; display compilation windows
          (TeX-global-PDF-mode t)       ; PDF mode enable, not plain
          (setq TeX-save-query nil)
          (imenu-add-menubar-index)
          (define-key LaTeX-mode-map (kbd "TAB") 'TeX-complete-symbol)))

I tried to add (add-to-list 'tex-compile-commands '("xelatex --shell-escape -interaction nonstopmode -output-directory %o %f" t "%r.pdf")), but that doesn't help.

1 Answer 1

2

Add the following line to the list of local variables of the source file:

%%% TeX-command-extra-options: "-shell-escape"

Then you need to do M-x revert-buffer to make it applied.

AUCTeX 12.2: 4.1.3 Options for TeX Processors

How to pass flags to the LaTeX compiler with AUCTeX? - Emacs Stack Exchange

emacs - Adding an option to the PDFLaTeX call from AUCTeX - LaTeX Stack Exchange

4
  • Are you assuming that one needs AUCTeX for your solution? What if I'm using plain vanillatex-mode? I tried your solution, it didn't work. Commented Dec 12, 2023 at 10:40
  • @OskarLimka I don't think AUCTeX is a must, since I use describe-variable to find TeX-command-extra-options is defined in tex.el. It has been a long time since last time I used latex in emacs, I almost forgot how things go. I think you can try to find if the value of TeX-command-extra-options was passed to tex engine first.
    – Ynjxsjmh
    Commented Dec 12, 2023 at 14:56
  • thank you. This is how the first line of my master latex file looks like %%% -*- mode: latex; reftex-mode: true; coding: mule-utf-8; TeX-command-extra-options: "-synctex=1"; -*- but when I xelatex compile by running 'C-c C-c` emacs issues xelatex \\nonstopmode\\input lecture.tex in the *tex-shell* buffer. Commented Dec 13, 2023 at 9:17
  • 1
    @OskarLimka I don't know what does ; mean in your first line, the format looks werid to me. I use it like this.
    – Ynjxsjmh
    Commented Dec 13, 2023 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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