4

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

\documentclass{article}
\begin{document}
asdf
\end{document}
%%% 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

3
  • 4
    It is %%% TeX-engine: luatex. (You are naming the engine with the variable, not the format.)
    – jon
    Commented Mar 3, 2017 at 19:57
  • @jon I see, that was the mistake. Can you formulate your comment as a reply? Then I can mark my question as answered.
    – jpb
    Commented Mar 3, 2017 at 20:07
  • 4
    When you open the file with lualatex as engine, you should be warned that it isn't a safe value, because it isn't valid. Anyway, I fixed the freeze in AUCTeX, now you should get a meaningful error instead of freezing Emacs when an invalid engine is set.
    – giordano
    Commented Mar 4, 2017 at 10:31

1 Answer 1

7

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:

((latex-mode    
  (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:

((latex-mode
  (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.

4
  • Great answer. Is there a way to cause AUCTeX to generate the line %%% TeX-engine: luatex automatically, the same way it does the other file-variable directives?
    – Evan Aad
    Commented May 31, 2017 at 14:54
  • 1
    @EvanAad -- Wouldn't you rather change the default engine? (E.g., in .emacs: (setq-default TeX-engine 'luatex) and, probably, (setq-default TeX-PDF-mode t).)
    – jon
    Commented Jun 1, 2017 at 3:47
  • Thanks. What does TeX-PDF-mode do?
    – Evan Aad
    Commented Jun 1, 2017 at 5:29
  • 1
    @EvanAad -- It sets whether you want output to be PDF or not by default. (Note: it is also possible to add a command so your Local Variables includes the line you want. I'm not sure which approach is more suitable in your case.)
    – jon
    Commented Jun 1, 2017 at 5:45

You must log in to answer this question.

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