[Tex/LaTex] Emacs + auctex freezes when compiling with lualatex


Trying to compile the following using C-c C-c in emacs + auctex freezes emacs:

%%% Local Variables:
%%% TeX-engine: lualatex
%%% TeX-master: t
%%% End:

Is there a mistake in my local variables? I was following following advice: link. My emacs and my auctex should be up to date.

emacs version: GNU Emacs 25.1.1

auctex version: 11.90.0

Best Answer

With the "Local Variables" settings, you may declare the 'engine' that Emacs will call. Usually your choice will be one of default¹ luatex, or xetex. The mode, conversely will name the format you are using (e.g., context, latex, or tex).

Thus, for a LaTeX document that requires the LuaTeX engine, which you'd normally call with the command lualatex in a terminal, you could use the following:

%%% Local Variables: 
%%% mode: latex 
%%% TeX-engine: luatex
%%% TeX-master: t 
%%% End:

When Emacs opens a new .tex file in the buffer, it queries what my master file will be (default is t, which means the current new file/buffer will be its own master) and presumes the latex format. Now, if I want to specify the engine, I can add the TeX-engine line. You can also temporarily select the engine (for the remainder of the time Emacs is visiting the file with M-x TeX-engine-set RET <default|luatex|xetex> RET.

Another thing you can do for a whole directory is create a file called .dir-locals-el that contains the line:

  (TeX-engine . luatex)))

This sets the default engine for the directory to luatex. If you want to name the master file, you could additionally do:

  (TeX-engine . luatex)   
  (TeX-master . "mainfile"))) ;; now mainfile.tex is the master file for the directory

¹ My .emacs has pdfTeX as my default engine, which is surely what the default default is; but this could be changed.

Related Question