1

AUCTeX automatically parses my headers and determines what packages I use, making adjustments accordingly. For example, it knows when I've used cleveref and changes the available types of references when I type C-c ) accordingly.

However, if I precompile my preamble, AUCTeX does not know what packages I am using. Is there a way that I can set a variable to convince it to parse the header files, which are never included explicitly (except via the special comment %&preamble)?

It would be a bonus if I could also convince AUCTeX to precompile the header, which I currently do from the command line.

tgkolda
  • 704

1 Answers1

2

I'm not sure if you can achieve what you're looking for by setting a variable. Not tested, but I can think of the following:

  1. Start Emacs, open a .tex file so that AUCTeX is loaded. Then do M-x TeX-auto-generate RET. When asked for a TeX file, enter the preamble.tex. When asked for an AUTO directory, take /path/to/your-tex-file/auto or the directory which is stored in TeX-auto-private. Emacs should parse and save a preamble.el there.

  2. In your .tex file, add the following line to the file local variables:
    %%% eval: (TeX-run-style-hooks "preamble").
    The entire block should look like this:

    %%% Local Variables:
    %%% mode: latex
    %%% TeX-master: t
    %%% eval: (TeX-run-style-hooks "preamble")
    %%% End:
    
  3. Now restart Emacs and load your .tex file and see if this works by hitting C-h e: You should see if AUCTeX style files were loaded.

For the bonus question, I'd suggest you try to add a command for preamble pre-compilation to TeX-command-list.

Arash Esbati
  • 7,416
  • As you say, this is not just setting a variable. But it worked for me! Many thanks for the guidance. I accepted the answer. – tgkolda Mar 17 '21 at 00:41