Generalxr package

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

xr package

Post by jamesm »

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

Latex Code:

Code: Select all

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:

Code: Select all

\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: xr package

Post by josephwright »

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

xr package

Post by jamesm »

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:

Code: Select all

\documentclass{article}
\usepackage{xr}

\externaldocument{external} %aux files are in same folder

\begin{document}

See Section \ref{newsec}.

That's it!

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

Code: Select all

\documentclass{article}
\usepackage{hyperref}
\begin{document}

\section{This new section} \label{newsec}
This is an external file.

\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

Code: Select all

\documentclass{article}
\begin{document}

\section{This new section} \label{newsec}
This is an external file.

\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

xr package

Post by jamesm »

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

Code: Select all

\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.
camiort
Posts: 1
Joined: Sun Sep 08, 2013 1:09 am

Re: xr package

Post by camiort »

Thank you for posting the solution!
Post Reply