[Tex/LaTex] Appendices in separate file (Cross Referencing)

appendicescross-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?

Best Answer

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}
\begin{equation}
  E = m c^2
  \label{eq:Einst}
\end{equation}
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}
\begin{equation}
  \mathrm{e}^{i\pi}-1 = 0
  \label{eq:e}
\end{equation}
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

Related Question