I have not been using LaTeX for quite some while, so I might be missing something obvious. I have a multiple file document and want to make AUCTeX aware of the master file. The minimal example looks like this: A master file test.tex and one section in test-1.tex in the same directory.








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



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

If I compile test.texvia C-c C-c everything works fine but if I am in test-1.tex I get the following error:

ERROR: Undefined control sequence.

--- TeX said ---
l.1 \section
--- HELP ---
TeX encountered an unknown command name. You probably misspelled the
name. If this message occurs when a LaTeX command is being processed,
the command is probably in the wrong place---for example, the error
can be produced by an \item command that's not inside a list-making
environment. The error can also be caused by a missing \documentclass

Also Switch to master file C-c ^ does not work, so there is something not working with the multiple file parsing. I have tried C-u C-c C-n to reset AUCTeX without any effect. What am I missing?

  • 2
    What's the value of the variable TeX-parse-self? Have you tried to hit C-c C-n in test-1.tex and in test.tex? Your example works without a problem for me -- I have set TeX-parse-self to t. – Arash Esbati Mar 25 '19 at 13:32
  • TeX-parse-self is set to t in my config and I tried C-c C-nin both documents without any change. It is still not working. – Martin Buchmann Mar 25 '19 at 19:58
  • 1
    Sorry, hard to tell. I suggest you start debugging. The usual way is to update AUCTeX to the latest version from ELPA, start Emacs with the -Q switch, eval (package-initialize) and open your .tex file. This works for me as well. – Arash Esbati Mar 26 '19 at 22:17
  • I will see when I have the time for real debugging and will post my results here. – Martin Buchmann Mar 27 '19 at 9:30

Thanks to the encouraging comments I was able to work it out. I added turn-on-outline-minor-mode to LaTeX-mode-hook for historical reasons and it breaks the multiple files parsing. I have no idea what is happening under the hood but can easily live without it.

With this config everything works fine:

(use-package tex
  :ensure auctex
  (setq TeX-auto-save t
        TeX-parse-self t
        TeX-save-query nil)
  (setq-default TeX-master nil)
  (LaTeX-mode . flyspell-mode)
  (LaTeX-mode . flyspell-buffer)
  (LaTeX-mode . tex-fold-mode)
  (LaTeX-mode . turn-on-reftex))
  • 1
    I don't use-package, but the following (add-hook 'LaTeX-mode-hook #'outline-minor-mode) works for me and doesn't break AUCTeX. – Arash Esbati Apr 3 '19 at 15:30
  • Weird! I am traveling right now and can’t check. But even with a vanilla config using -Q this line caused trouble. – Martin Buchmann Apr 3 '19 at 16:04

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.