I'm using Emacs 24.5 with AUCTeX and RefTex to edit a multi-file project. It consists of one main file with %%% TeX-master: t to mark as master. The 'slave' files all have %%% TeX-master: main to link them to the master file.

RefTex can correctly find the bibliography defined on the master file. However reftex-toc only works for the master file. On any slave file it shows only entries for that single file.

How can I make reftex-toc aware of multiple files so I can quickly jump into other sections of the document defined in other slave files?

  • This feature should work out of the box, provided that TeX-master is correctly set. In the secondary files, how do you indicate the master file? It must be a string with the relative path to the master file, without extension, so it should be %%% TeX-master: "main", with quotes, if the master file resides in the same directory as the secondary files and is called main.tex.
    – giordano
    Feb 2 '16 at 8:57
  • Thank you again giordano. The issue was with the quotes. Adding double quotes around the master file name solved the issue and now I have reftex-toc working on every project file. Thanks! Feb 2 '16 at 16:37

This feature should work out-of-the-box, provided that TeX-master is correctly set. The format of that variable is described at (info "(auctex)Multifile"). In particular, in the secondary files TeX-master should be a string with the relative path to the master file, without extension. Thus, if your master file is called main.tex and resides in the same directory as the secondary files you should have

%%% TeX-master: "main"

with quotes around main.

Note that there is a handy function that can help you to insert the right value of TeX-master: TeX-master-file-ask, bound to C-c _.

Note also that it's strongly suggested to put the line

(setq-default TeX-master nil) ; Query for master file.

in your init file, so that you'll be always prompted for the master file (just press RET to select the current file as master file) every time you create a new *TeX file.

While we are at it, add to your init file also the lines

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

to enable all the parsing infrastructure that makes AUCTeX great. All these settings are suggested in the very first lines of the AUCTeX manual.

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.