[Tex/LaTex] How to use reftex in multiple files

bibliographiesbibtexincludereftex

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

\include{chapter1}
\section{test} hello POS
\include{chapter2}
\include{chapter3}
\bibliographystyle{amsplain}
\bibliography{mybibliography}

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:

\section{introduce}
....
\subsection{result}

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.

Best Answer

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.

Related Question