# Appendices in separate file (Cross Referencing)

I have a big report with appendices. Now I would like to put my appendices in a separate file. That's no problem at all. But I refer to my appendices in my main file. What would be the easiest way to refer to my appendices in my main file, while the appendices themselves are separate?

Right now I have my appendices both in my main file and a separate appendices file and made sure the page numbering is the same. But now I have my appendices in my main file while I dont need them there.

Is there some easier way to do this?

Short version: is there some easy way to crossrefer to another latex file?

-
User the xr package (or xr-hyper), have a look at How to reference another document in LaTeX. If the answer there can already help you, we could close this question as a duplicate with link to that answer. –  Stefan Kottwitz Apr 17 '11 at 14:39
possible duplicate of \ref'erencing \label's from other files –  Alan Munn Apr 17 '11 at 14:39
Reading both the links u gave me, gimme a minute to see if that covers my question. –  Elmer Apr 17 '11 at 14:45
I took a look at the xr and xr-hyper packages. There aint too much documentation on it. They seem to assume both latex files are in the same folder. Would it be possible also to refer to a file in a complete different folder? –  Elmer Apr 17 '11 at 14:51
Maybe what you want to do is better served with \include/\includeonly. See When should I use \input vs \include ? for more information on this. –  Alan Munn Apr 17 '11 at 15:25

Here is an example with the refstyle and xr packages (you need some work to get the TOC right). Create your main file, say Main.tex

\documentclass{report}
\usepackage[nokeyprefix]{refstyle}
\usepackage{varioref}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[A-]{App-A}
\externaldocument[B-]{App-B}
\begin{document}
\chapter{First}
$$E = m c^2 \label{eq:Einst}$$
In \eqref[s]{eq:Einst} and \eqref*[xr=A-, vref]{eq:e} ...
\end{document}


Then create the Appendix, say App-A.tex

\documentclass{report}
\usepackage[nokeyprefix]{refstyle}
\usepackage{varioref}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[Main-]{Main}

\begin{document}
\appendix
\setcounter{chapter}{0}
\setcounter{page}{50}
\chapter{First}
$$\mathrm{e}^{i\pi}-1 = 0 \label{eq:e}$$
In \eqref[s,xr=Main-,vref]{eq:Einst} and \eqref*{eq:e} ...
\end{document}


Compile both then the hyperlinks will be active and you can jump between the pdf files

-