[Tex/LaTex] Cross-referencing across folders

cross-referencingxr

I have multiple documents which require cross-referencing from one another (I am the author of all of them). Each document lies in a separate folder.

As an example, everything lives in a directory named "main-folder". Within this directory, I have two directories: "folder-1" and "folder-2". Within each directory (folder-1 and folder-2) lives a TeX document, say file-1.tex is in folder-1 and file-2.tex is in folder-2.

I am using the xr package, and when two TeX documents needing cross-referencing are within the same directory (say, both in folder-1), I enter the following two lines in the preamble of file-1.tex:

\usepackage{xr}
\externaldocument[someprefix-]{file-2}

and this allows me to cross-reference labels from file-2.tex in file-1.tex via the usual \label and \ref commands, using someprefix- to distinguish between the labels in file-1.tex and those in file-2.tex.

I am wondering what the syntax should be if file-2.tex is in folder-2 instead of folder-1. I have already tried:

\externaldocument[someprefix-]{../file-2}
\externaldocument[someprefix-]{~/...insert-relevant-directory-here.../folder-2/file-2}

but nothing works. What am I doing wrong?

Best Answer

This should work:

\externaldocument[someprefix-]{../folder-2/file-2}

Notice: Do not include the .tex extension.

Related Question