Is there a way to cause AUCTeX to automatically generate the line
%%% TeX-engine: luatex
in a new .tex
document as it does with other file-variables, such as TeX-master
?
Add the following code to your init file:
(add-hook
'find-file-hook
(lambda ()
(when (eq major-mode 'latex-mode)
;; Check if we are looking at a new or shared file.
(when (or (not (file-exists-p (buffer-file-name)))
(eq TeX-master 'shared))
(add-file-local-variable
'TeX-engine
(intern (completing-read "Add TeX-engine with value: "
(mapcar 'car (TeX-engine-alist)) nil nil nil nil "default"))))
(TeX-update-style t))))
This is inspired by how AUCTeX asks you for master file when you create a new file.
.emacs
, right? (setq-default TeX-engine 'luatex)
Enter
in reply to the question Add TeX-engine with value:
without specifying a value, the current default value (pdfTeX?) will be selected, or better yet, the TeX-engine
file-variable won't get written at all, which is the current behavior?
mode
file-variable is set automatically to latex
regardless of the TeX-engine
setting. Is this the correct behavior? To make the question more concrete, if my .tex
document is written in the LuaLaTeX dialect and I wish to compile it with the luatex
program, is it enough to set the TeX-engine
file-variable to luatex
or will the fact that the mode
file-variable is set to latex
cause any trouble? Does the mode
file-variable definition need to be deleted, or changed, say, to lualatex
?
latex-mode
is to distinguish between plain TeX, LaTeX, docTeX, ConTeXt, TeXinfo, see gnu.org/software/auctex/manual/auctex.html#Modes-and-Hooks It has nothing to do with the actual engine used ;-) AUCTeX is one of the few editors I know that correctly keeps the language and the engine used separated: e.g., you can compile with luatex engine a plain TeX document.
C-c C-m usepackage RET fontspec RET
in your .tex file and AUCTeX will ask you for an engine with completion incl. adding your choice to your file.fontspec
is not mandatory (like it isn't mandatory to set any font withpdftex
), but it's often used.