0

I am encountering a similar problem to this very old question, in that AUCTeX is not autocompleting commands outside the TeX-master file.

I have the following files:

main.tex:

% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex
% arara: latexmk: { clean: partial }
\documentclass{report}

\usepackage{amsmath}

\begin{document}
What follows are some equations.
\input{sections/equations}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

and a subordinate file

sections/equations.tex

\section{Some equations}

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

The problem is that while loading the amsmath package in main.tex, the corresponding environments (e.g. \align) are only autocompletable in main.tex, and not in sections/equations.tex. As it appears that AUXTeX should support this behavior out-of-the-box (see the documentation), what am I missing?

Emacs config.org

As I think the error might originate from my Emacs configuration, the relevant Emacs configuration for AUXTeX is:

(use-package tex
    :ensure auctex
    :config
    (setq-default TeX-master nil)
    (setq TeX-auto-save t
          TeX-parse-self t)
    (setq font-latex-fontify-sectioning 'color)  ;; Disable fontification, e.g. \section
    (setq reftex-plug-into-AUCTeX t)
    (setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource"))
    ;; Add Zathura as default (see below)
    (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))
    ;; Add hooks
    :hook ((LaTeX-mode . turn-on-reftex)              ;; Turn on RefTeX
           (LaTeX-mode . eglot-ensure)                ;; Turn on eglot (LSP)
           (LaTeX-mode . TeX-source-correlate-mode)   ;; Correlated PDF and tex file       
           (TeX-after-compilation-finished-functions . TeX-revert-document-buffer)))
4
  • With your setup above, do you get a file ./auto/main.el under the directory where you main.tex resides when you save main.tex? It should look like this: (TeX-add-style-hook "main" (lambda () (TeX-run-style-hooks "latex2e" "sections/equations" "report" "rep10" "amsmath")) :latex) Jul 14, 2023 at 8:31
  • Yes I do, the contents are more verbose that your example, but does include the part that you mention. I also want to add that environment completion using C-c C-e does work, the autocompletion simply does not trigger when inserting \align (which does trigger completing the align environment in main.tex). Jul 14, 2023 at 9:12
  • So you expect you insert \align in the buffer and you get \begin{align}...\end{align} completion? Where have you read about this feature of AUCTeX? Or maybe this is a feature of the LSP-Server you're using? Jul 14, 2023 at 18:04
  • This is indeed what I expect, but now that you mention it this might actually be the LSP server, and not AUCTeX. Jul 15, 2023 at 14:49

0

You must log in to answer this question.

Browse other questions tagged .