I use Emacs+AUCTeX to write my *-tex. Using the PDF mode, I can run pdfTeX automatically with the C-c C-c command. However, I don't see a way to run XeTeX automatically, or even set up a command option in the drop down window. My LISP skills are very rusty, and I was wondering if someone had a tex.el patch to enable XeTeX support ?

4 Answers 4


If you have AUCTeX version 11.86, you can set the local variable TeX-engine to xetex. This is what I use:

%%% Local Variables: 
%%% coding: utf-8
%%% mode: latex
%%% TeX-engine: xetex
%%% End: 

You have to open the file again for the effect to take place (C-x C-v).

You can check the version you have with

C-h v AUCTeX-version <RET>
  • is there a relatively easy way to check the version of auctex I have ?
    – Suresh
    Commented Jun 20, 2011 at 20:46
  • 1
    Where do we have to put those directives? inside tex files or...
    – user11232
    Commented May 13, 2013 at 17:48
  • 1
    @HarishKumar At the very end of the TeX file.
    – egreg
    Commented May 13, 2013 at 17:49
  • 3
    for some reason these directives didn't change the TeX-engine to xetec using Emacs24.4 on Windows7!
    – doctorate
    Commented Dec 31, 2014 at 9:25
  • 3
    @doctorate The directives are read when you visit (open) the file. Close the file then open it again.
    – Jas Ter
    Commented Mar 31, 2017 at 7:34

You can add this to your emacs.el:

(setq-default TeX-engine 'xetex)

And add this if you want a PDF output by default:

(setq-default TeX-PDF-mode t)
  • 6
    Personally, I'd enable PDF output globally (with your syntax) but I'd set the TeX engine locally. Commented Mar 16, 2013 at 18:22

For versions 11.86 and higher,¹ there is also

M-x TeX-engine-set RET xetex RET

which will make AUCTeX compile that particular file with XeTeX (or xelatex if the file is considered a LaTeX file). Note that this 'setting' will only continue to work so long as emacs is visiting that file. Often useful if you forgot to set the local variables, or you want to quickly compare how different engines compile the same document. Since PDFTeX can be much faster than other engines (esp. LuaTeX), I often use it while writing my documents, and only switch to LuaTeX in the final stage(s). Resetting the Local Variables all the time is not ideal for that.

¹ Actually, I'm not sure when this command was added....


You could customize the Tex Command List:

   M-x customize-variable TeX-command-list

There you can add a new commands to AUCTeX. Alternatively, you can directly modify your emacs init file:

;; set XeTeX mode in TeX/LaTeX
(add-hook 'LaTeX-mode-hook 
             (add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
             (setq TeX-command-default "XeLaTeX")
             (setq TeX-save-query nil)
             (setq TeX-show-compilation t)))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .