TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to cross-reference between different .tex files, just because I want to put every chapters separately.

Let's say in file chapterI.tex I have \label{a} and I want to access this in file chapterII.tex using something like \ref{a}. How to do this exactly in LaTeX, moreover if LEd have an easy feature to cover this, it will be better (I have put those both files in the same project).

I found another question with similar title, but I just didn't really understand. It's here: Cross reference between latex files.

share|improve this question
You can certainly make a cross-reference across files like you want. \label{a} in one file, and \ref{a} in another. What's not working? Is there a minimal working example that shows the problem? – Mike Renfro Mar 27 '11 at 16:20
@Mike: and how to "compile" it into pdf or dvi exactly? I tried to do that, and it's still ?? after several tries. – zfm Mar 27 '11 at 16:27
Sorry, just to clarify it: Are the chapters all part of one document or are they all separated documents? In the first case it should work out of the box like @Mike said. The second case is described in my answer. – Martin Scharrer Mar 27 '11 at 16:29
@zfm: Since your accepted answer has nothing to do with LEd, perhaps you might change your title to "Cross reference between files in LaTeX" so that the question has broader appeal. – mforbes Sep 14 '11 at 23:39
@mforbes: will do it! – zfm Nov 8 '11 at 19:04
up vote 78 down vote accepted

You can use the xr package to reference to other LaTeX document.

So in chapterII.tex you say:


And then can use \ref{a} like normal. You can also add a prefix:


then you can reference it as \ref{I-a} which is useful if you have identical label names in different chapters.

Note that the normal xr doesn't add hyperlinks. It only adds the label text. The zref package can be used for this. It provides the zref-xr subpackage which gives you the same functionality and should work fine with hyperref (after all both packages are from the same author). You only need to replace \externaldocument with \zexternaldocument.

share|improve this answer
work perfectly, thank you! – zfm Mar 27 '11 at 16:41
@Martin: It might be useful to mention that you need to replace \usepackage{xr} with \usepackage{zref-xr}`. (I was not sure what a "subpackage" was when I first read your answer.) – mforbes Sep 14 '11 at 23:34
@Martin: I am stumped: how do you get hyperref to work with zref-xr? Using \zref and \zlabel (with \usepackage{zref-user}) generates the labels properly, but I cannot get hyper refs working. Could you please post a MWE or should I ask a related question emphasizing the hyperref aspect? – mforbes Sep 15 '11 at 6:05
@mforbes: Did you solve this? I posted it as a new question some days ago. – Carsten Thiel Aug 13 '13 at 7:35
@CarstenThiel Nope. – mforbes Aug 14 '13 at 1:24

Beamer and xr: If you want to use the xr package to pull external references into a Beamer document, you need to be sure that the source of the references has been typeset using the hyperref package. This is because Beamer uses hyperref by default and the format of the references in the .aux file is different for hyperref. If the references are coming from another Beamer document, there is no need to do anything. If they are coming from a basic LaTeX document you may need to add \usepackage{hyperref} and typeset the source document again. As far as I can tell, there is no downside to always using hyperref.

share|improve this answer

I just made this, based on http://tex.stackexchange.com/a/46493/85164. You could have a personal wiki of pdfs.






Topics include
\item \wiki{test}

share|improve this answer
The package hyperref should be (in the most cases) the last in the preamble. To me it is not clear, how the your answer is related to the question. Can elaborate this in your answer? – Zarko Jan 22 at 9:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.