Generalhyperref to external file -how to display external file name

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Faerine
Posts: 1
Joined: Sat Nov 29, 2008 4:57 am

hyperref to external file -how to display external file name

Post by Faerine »

I am using the hyperref and hyper-xr packages to create hyperlinks to labels in external files. (I am compiling the .tex files with pdflatex).

E.g., inside a file named test7.tex, I have:

Code: Select all

\Chapter{test7 chapter}
\label{ch:test}
Then, in the preamble of a file named test8.tex

Code: Select all

\externaldocument[7-]{test7}
and in the file's body:

Code: Select all

Now go to \autoref{7-ch:test}, \Nameref{7-ch:test}
Assuming both files are compiled correctly, the code above will produce
Now go to chapter 1, "test7 chapter", on page 1
in test8.pdf and this will link to the appropriate place in test7.pdf. However, even though the links go to the correct external file, the text produced by \autoref and \Nameref doesn't list the name of the file itself. I would like to have this for human readability -- e.g., something like
Now go to chapter 1, "test7 chapter", on page 1 of file test7
where "of file test7" is generated automatically by a command similar to \autoref and \Nameref. However, I could not find such a command or any other ways to do this. Any pointers will be greatly appreciated.

Recommended reading 2024:

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

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

jkow
Posts: 2
Joined: Mon May 13, 2013 3:44 pm

Re: hyperref to external file -how to display external file

Post by jkow »

Hi, I am also facing this problem and am already digging into the hyperref code to find a solution. Before I waste too much time on the topic.... did you find a way to display the document name?
jkow
Posts: 2
Joined: Mon May 13, 2013 3:44 pm

hyperref to external file -how to display external file name

Post by jkow »

In case anyone is interested, i defined the macro \refurl to grab the url from the internal reference command:

Code: Select all

\def\refpartfive#1#2#3#4#5{%
#5
}

\newcommand{\refurl}[1]
{%
\expandafter\expandafter\expandafter\refpartfive\csname r@#1\endcsname{}
}
So now I am able to write

Code: Select all

Now go to \autoref{7-ch:test}, \nameref{7-ch:test}
in file \refurl{7-ch:test}.
Post Reply