File documentA.tex
\documentclass{article}
\begin{document}
\section{Section in document A}\label{Asection}
\end{document}
File documentB.tex
\documentclass{article}
\usepackage{xr}
\externaldocument[documentAPrefix-]{documentA}
\begin{document}
\section{Section in document B}\label{Bsection}
This are references to section of document A:
ref: \ref{documentAPrefix-Asection}
pageref: \pageref{documentAPrefix-Asection}
\end{document}
First compile documentA.tex in order to obtain documentA.pdf.
During this compilation, beneath other things, the file documentA.aux comes into being.
Keep that file. Don't have it deleted.
Then compile documentB.tex.
I suggest doing this on the shell-prompt (bash/LXTerminal/command.com/whatever you use) :
On the prompt of your shell change to the directory/folder where both documentA.tex and documentB.tex are saved. (The command for changing to a directory or folder is chdir
or cd
or the like.)
Then two or three times use the command pdflatex documentA.tex
.
Then two or three times use the command pdflatex documentB.tex
.
Besides documentA.pdf and documentB.pdf you will get files of extension .log and .aux as well. The .aux-files are of interest for the \externaldocument
-command. ;-)
hyperref
package?