1

When I divide a document between a master file and other buffers, I don't get hints from AucTeX to complete environments and macros. I set the master file with:

 %%% TeX-master: "mymasterfile"

Compilation and viewing work correctly. But, for example, if the master file uses beamer, pressing C-c C-e in a buffer, AuCTeX doesn't suggest me the frame environment (it does correctly in the master file). How can I make the buffer aware of the class load in the master file?

  • 1
    What do you get if you hit C-h v TeX-parse-self RET in your child file? Does it help if you hit C-c C-n in your master file and then in your child file as well? – Arash Esbati Jan 15 at 10:36
  • C-h v TeX-parse-self RET gives t as the current value of the variable. Actually, going back to the master and hitting C-c C-n there and in the child works! How can I make it autmoatic? – TeXtnik Jan 16 at 10:54
1

AUCTeX manual has provides:

5.2 Multifile Documents

[...] AUCTeX keeps track of macros, environments, labels, and style files that are used in a given document. For this to work with multifile documents, AUCTeX has to have a place to put the information about the files in the document. This is done by having an auto subdirectory placed in the directory where your document is located. Each time you save a file, AUCTeX will write information about the file into the auto directory. When you load a file, AUCTeX will read the information in the auto directory about the file you loaded and the master file specified by TeX-master. Since the master file (perhaps indirectly) includes all other files in the document, AUCTeX will get information from all files in the document. This means that you will get from each file, for example, completion for all labels defined anywhere in the document.

AUCTeX will create the auto directory automatically if TeX-auto-save is non-nil. Without it, the files in the document will not know anything about each other, except for the name of the master file.

Next section gives more information:

5.3 Automatic Parsing of TeX Files

AUCTeX depends heavily on being able to extract information from the buffers by parsing them. Since parsing the buffer can be somewhat slow, the parsing is initially disabled. You are encouraged to enable them by adding the following lines to your .emacs file.

(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t) ; Enable parse on save.

The latter command will make AUCTeX store the parsed information in an auto subdirectory in the directory each time the TeX files are stored. If AUCTeX finds the pre-parsed information when loading a file, it will not need to reparse the buffer. The information in the auto directory is also useful for multifile documents, since it allows each file to access the parsed information from all the other files in the document. This is done by first reading the information from the master file, and then recursively the information from each file stored in the master file.

The variables can also be done on a per file basis, by changing the file local variables.

%%% Local Variables:
%%% TeX-parse-self: t
%%% TeX-auto-save: t
%%% End:

Even when you have disabled the automatic parsing, you can force the generation of style information by pressing C-c C-n. This is often the best choice, as you will be able to decide when it is necessary to reparse the file.

  • Thanks. I missed (setq TeX-auto-save t) in my `.emacs – TeXtnik Jan 21 at 11:23

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.