2

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?

2
  • 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
    Commented Feb 2, 2016 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! Commented Feb 2, 2016 at 16:37

1 Answer 1

4

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.

1
  • [This refines the previous answer. It should have been a comment but I am new and don't have enough points to answer.] The piece above about: "In particular, in the secondary files TeX-master should be a string with the relative path to the master file, without extension." Has not been the case for me. I use absolute path with extension and that works for me. The quotes are of course needed. I create my file local variables segments with org dynamic blocks and in that situations use of the extension and abs path works better. Also, for master files, I use the .mastex instead of .tex. So withou Commented Feb 18, 2023 at 21:12

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.