I have a file with the following content, let's call it tmp.tex


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

and another file main.tex that includes the previous file

\begin{document} \input{tmp} \end{document}

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

This works. I can open the file tmp.tex and run a compilation command on it. However, I tried moving all my variables to directory level by creating a file .dir-locals.el in the same directory with the following content

  (TeX-master . "main")))

and changed the content of tmp.tex to \emph{Hello} only. Now, if I open the file tmp.tex, the variable TeX-master is not set! Upon closer inspection, the mode that tmp.tex defaults to is plain-tex-mode rather than latex-mode. Of course, I can solve one issue by changing the mode in .dir-locals.el, but it would still mean that the file tmp.tex will not be opened in latex-mode by default.

This is strange, since previously, when I had the comments setting the local variables, the default mode was latex-mode rather than plain-tex-mode.

Is there a way to fix this besides having file-local variables?

  • In your file-local approach you are setting the major mode to latex-mode with the mode: latex entry. If you remove that, you will need to use some alternative approach to enforcing the desired mode. i.e. "the default mode was latex-mode rather than plain-tex-mode" is (presumably) not true. – phils Oct 29 '18 at 21:38

Your Answer

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

Browse other questions tagged or ask your own question.