## LaTeX forum ⇒ General ⇒ xr package Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
jamesm
Posts: 13
Joined: Sun Aug 09, 2009 5:01 pm

### xr package

Hi
I'm having problems with the xr (cross-reference) package.
It happens with every call I make to "external" aux files.

Latex Code:
1. Proposition \ref{prop:splitting lemma}.

Output:
Proposition 4.12Splitting Lemmatheorem.4.12.

Should just be:
Proposition 4.12.

The relevant line in the "external" aux file is:
1. \newlabel{prop:splitting lemma}{{4.12}{41}{Splitting Lemma\relax }{theorem.4.12}{}}

Any suggestions?

Thanks, James

If it's relevant, I'm using Miktex 2.7 on Vista. And I have tried disabling all the other packages in the preamble in case there's a conflict, and there isn't.
Last edited by cgnieder on Sun Sep 08, 2013 10:57 am, edited 2 times in total.
Reason: code markup

Tags:

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm
Please post a minimal example: an isolated snippet will not really help here!
Joseph Wright

jamesm
Posts: 13
Joined: Sun Aug 09, 2009 5:01 pm
Aha - thanks for making me analyze it better. It seems to be a conflict with how the package hyperref effects labels.

We're talking about cross-referencing so I need two files. The main one is text.tex:
1. \documentclass{article}
2. \usepackage{xr}
3.
4. \externaldocument{external} %aux files are in same folder
5.
6. \begin{document}
7.
8. See Section \ref{newsec}.
9.
10. That's it!
11.
12. \end{document}

Then in the other file (called by xr) - say external.tex - I either include hyperref or not. Here are the two cases,

1. \documentclass{article}
2. \usepackage{hyperref}
3. \begin{document}
4.
5. \section{This new section} \label{newsec}
6. This is an external file.
7.
8. \end{document}

The file external.aux then contains the following line:
\newlabel{newsec}{{1}{1}{This new section\relax }{section.1}{}}
with the result that compiling text.tex gives the line,
See Section 1This new sectionsection.1.
That’s it!

Without hyperref, the following code
1. \documentclass{article}
2. \begin{document}
3.
4. \section{This new section} \label{newsec}
5. This is an external file.
6.
7. \end{document}

In this case, the file external.aux then contains the following line:
\newlabel{newsec}{{1}{1}}
And the reult of compilation is as it should be,
See Section 1.
That’s it!

Is there anyway to make hyperref and xr work together?[/quote]

Thanks again, James

jamesm
Posts: 13
Joined: Sun Aug 09, 2009 5:01 pm
I can answer my own question, if anyone's interested.
If hyperref is used in the "external file", then it must also be used in the main file. If I add
1. \usepackage{hyperref}

to the first piece of code in my previous post above, then it works fine (even though I'm not interested in having hyperlinks in the main file). It doesn't seem to matter whether \usepackage{hyperref} is placed before or after \usepackage{xr}.

Thanks again. James
Last edited by cgnieder on Sun Sep 08, 2013 10:56 am, edited 1 time in total.
Reason: code markup

camiort
Posts: 1
Joined: Sun Sep 08, 2013 1:09 am
Thank you for posting the solution!