2

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.

test.tex

\documentclass[11pt,a4paper]{article}

\usepackage{lipsum}

\begin{document}

\section{First}
\lipsum[1]

\include{test-1}

\end{document}

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

test-1.tex

\section{Second}
\lipsum[2]

%%% 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
            {Second}
--- 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
command.

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?

4
  • 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. Commented Mar 25, 2019 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. Commented Mar 25, 2019 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. Commented Mar 26, 2019 at 22:17
  • I will see when I have the time for real debugging and will post my results here. Commented Mar 27, 2019 at 9:30

1 Answer 1

1

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
  :config
  (setq TeX-auto-save t
        TeX-parse-self t
        TeX-save-query nil)
  (setq-default TeX-master nil)
  :hook
  (LaTeX-mode . flyspell-mode)
  (LaTeX-mode . flyspell-buffer)
  (LaTeX-mode . tex-fold-mode)
  (LaTeX-mode . turn-on-reftex))
2
  • 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. Commented Apr 3, 2019 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. Commented Apr 3, 2019 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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