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

  • 4
    It is %%% TeX-engine: luatex. (You are naming the engine with the variable, not the format.) – jon Mar 3 '17 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 Mar 3 '17 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 Mar 4 '17 at 10:31
4

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.

  • 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 May 31 '17 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 Jun 1 '17 at 3:47
  • Thanks. What does TeX-PDF-mode do? – Evan Aad Jun 1 '17 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 Jun 1 '17 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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