# 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

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 2, "x-ck12": 0, "texerror": 0, "math_score": 0.8440039157867432, "perplexity": 1828.6616438941176}, "config": {"markdown_headings": true, "markdown_code": false, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-27/segments/1435376093097.69/warc/CC-MAIN-20150627033453-00142-ip-10-179-60-89.ec2.internal.warc.gz"}