Is there a way to make AUCTeX aware of the TeX engine local variable set in a master file when I compile from other files?




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


Here is some content.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "master"
%%% End:

When I am inside content.tex and pres C-c C-c, AUCTeX runs pdflatex and not lualatex.

  • Some comment (bit off topic): no need for minimal in the MWE, we prefer article (or scrartcl) for instance. – Manuel Mar 24 '14 at 0:21
  • 2
    For now, I'd just set it in the child files as well: TeX-engine is local to a buffer by default, and that variable does not seem to be parsed and added to the 'auto' sub-directory by default. (I assume this is an oversight that should be corrected.) Meanwhile, you can simply do a TeX-engine-set <RET> luatex <RET>` to make content.tex switch engines, which I'm sure you know already. It is likewise easy to set luatex as your default engine for all files, too. (Better Emacs hackers will hopefully chime in with a real answer.) – jon Mar 24 '14 at 2:40
  • 2
    Just as a design thought for a hero who writes up a solution: perhaps it would be good to create an alist (say, TeX-inherited-variables-alist) of variables to inherit from the file-local variables of the master. There is no such ready-made function, but you can grep for Local Variables: in files.el to find the sexp that handles it. – Sean Allred Mar 24 '14 at 3:45

If all LaTeX files in this directory will use the same engine, then you can set TeX-engine for all of them using Emacs per-directory local variables. Create a file in this directory named .dir-locals.el with the following contents:

  (TeX-engine . luatex)))

If all LaTeX files in this directory share the same master, then per-directory local variables are a convenient place to set this too:

  (TeX-engine . luatex)
  (TeX-master . "master")))

I find this more convenient than adding Local variables: sections to the end of each individual file. Of course, you can still use per-file local variables to override any of these if there are a few exceptional files to which these settings should not apply.

  • Ah, brilliant! Could've used this about a million times before now... – jon Apr 9 '14 at 2:01

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.