I tried some solutions but fail so far. I divide large data into multiple files and then include all of them in main file. I used emacs24. Here is general of my main.tex file

\section{test} hello POS

In the main.tex file, I enabled reftext-mode, and then ctrl+c+[, the reftex works for me and it asks me to type searched word for bibliography.

However, this operation fail when I switch to the chaper1.tex buffer, the error message is:

 **byte-code: No valid bibliography in this document, and no default available**

The chaper1.tex is like:


Clearly, the error message shows that chapter1.tex does not contain any \bibliography{mybibliography}, which already is in main.tex.

Since I do not want add any \bibliography in my chapter1.tex, how should I handle this error?


UPDATE: I also followed page: https://www.gnu.org/software/auctex/manual/auctex/Parsing-Files.html and tried the two solutions given below:

SOLUTION 1: Add these to .emacs/init.el file

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

OR SOLUTION 2: Add these declarations at beginning of each file

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

After restarting emacs and reenabling reftex-mode in chapter1.tex, the problem still occurs.

  • Are you using AUCTeX? If so, did you enable file parsing? – giordano Aug 5 '14 at 23:09
  • @giordano: Yes. I use AUCTEX. I have update but still fail. How to enable file parse? – shijie xu Aug 6 '14 at 1:27
  • It's described in the very first lines of the AUCTeX manual, see the sentence "If you want to make AUCTeX aware of style files and multi-file documents right away, insert the following in your .emacs file.". Guido's answer explain how to manually fix the problem for a single file, but adding those lines to your init file you'll be always automatically prompt for selecting the master file. – giordano Aug 6 '14 at 9:31

You can set a master file (main.tex). Thus you can include the following in all .tex files in your project.

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

After that, reftex will find the bibliography from the master (main.tex) file.

  • main and Main are two different files ;-) – giordano Aug 6 '14 at 9:31
  • Thanks @giordano. The Tex-master points to the main.tex file and then reftex works. – shijie xu Aug 6 '14 at 13:14
  • After inserting the above Local Variables, typing C-c C-n(CTRL+C and afterwards CTRL+n) will reread the configuration data, it found four your master document main.tex. From the manual Remove all information about this buffer, and apply the style hooks again. – Jan Dec 4 '19 at 15:30

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.