I have two documents file1.tex and file2.tex in two different folds fold1 and fold2, which are in the fold father.
In file1, I defined \label{file1:hello}, how do I use it in file2?
I have two documents file1.tex and file2.tex in two different folds fold1 and fold2, which are in the fold father.
In file1, I defined \label{file1:hello}, how do I use it in file2?
I replace here the same answer given for this question: in this case solutions are for files in the same folder.
You can use the xr package to reference to other LaTeX document.
In the file supplementmain.tex you say:
\usepackage{xr}
\externaldocument{supplement}
...
\ref{ext:supplement}
Note: normally xr doesn't add hyperlinks. Use zref package for this. You only need to replace \externaldocument with \zexternaldocument.
A minimal working example taken from the following site: GUIT
First.tex
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[S-]{Second}[Second.pdf]
\begin{document}
\chapter{One}\label{chp:one}
\chapter{Two}\label{chp:two}
Bla Bla Bla.
\end{document}
Second.tex
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[F-]{First}[First.pdf]
\begin{document}
\chapter{Beginning}\label{chp:One}
Hello!
\chapter{Continuation}
I read chapters~\ref{F-chp:one}~and~\ref{F-chp:two} of the first file.
\end{document}
GUIT also says that in this way you have the hyperlink to the first file.
If files are in different folders, you can add paths into \externaldocument
xrpackage would help. – Steven B. Segletes Feb 12 '14 at 20:51hyperref, then see Doeshyperrefwork between two files? – Werner Feb 12 '14 at 20:53\externaldocument{../fold2/file2}infile1.tex. Then you would use the label as-is:\label{hello}. Otherwise, if you may have duplicate labels (helloinfile1.texandhelloinfile2.tex), then you should use\externaldocument[<prefix>]{...}. – Werner Feb 12 '14 at 21:01