Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Relative path with \href and \url in hyperref

722 views
Skip to first unread message

L. Dwynn Lafleur

unread,
May 13, 2004, 7:29:05 AM5/13/04
to
System: Windows XP, Miktex.

I am using pdfLaTex to create a pdf document containing a link with an
outlined text description. I want that link to open an animated gif file in
a Web browser (Internet Explorer 6 in my case). The gif file is located in
the same folder (directory) as the pdf document, and I want the link to
point to the gif file using only a RELATIVE pathname.

Consider the document below which exists in the same folder as the animated
gif file "wavemovie.gif":

------------------------

\documentclass{article}
\usepackage[final,pdftex]{hyperref}
\begin{document}

\href{wavemovie.gif}{Link to animated gif} \hfill \url{wavemovie.gif}

\end{document}

--------------------------

When compiled with pdfLaTeX, this produces a pdf document in the same folder
as "wavemovie.gif". The first link has a text description as desired and
opens the Web browser, but a "Cannot find server" message is seen. The
second link only shows the name of the file, of course, and has no text
description. However, it opens up the browser and runs the movie
successfully.

The hyperref documentation states that \url{URL} is equivalent to
\href{URL}{URL}. However, we see they are not exactly equivalent since
\href cannot be used with the same relative pathname that \url can.

How can I use a relative pathname with \href? Any helpful comments would be
appreciated.


Dwynn

================================================
L. Dwynn Lafleur
Professor of Physics
University of Louisiana at Lafayette
laf...@louisiana.edu
http://www.ucs.louisiana.edu/~ldl6737/index.html
================================================

William F Hammond

unread,
May 13, 2004, 8:52:36 AM5/13/04
to
"L. Dwynn Lafleur" <laf...@louisiana.edu> writes:

> . . .


> \documentclass{article}
> \usepackage[final,pdftex]{hyperref}
> \begin{document}
>
> \href{wavemovie.gif}{Link to animated gif} \hfill \url{wavemovie.gif}
>
> \end{document}
>

> . . .


> The hyperref documentation states that \url{URL} is equivalent to
> \href{URL}{URL}. However, we see they are not exactly equivalent since
> \href cannot be used with the same relative pathname that \url can.

Hmm... Running pdflatex from TeXLive 2003 under RedHat, and then
running "strings -a" on the pdf output, I see:

/Subtype/Link/A<</Type/Action/S/URI/URI(file:wavemovie.gif)>>
...
/Subtype/Link/A<</Type/Action/S/URI/URI(wavemovie.gif)>>

Clearly different, as stated.


-- Bill

L. Dwynn Lafleur

unread,
May 20, 2004, 8:25:11 AM5/20/04
to
To reply to my own earlier post (see below), I was able to create a
new command \myhref that, contrast to \href, allows the same relative
pathname capability as \url. Using the internal command
\hyper@linkurl from \hyperref.sty, I wrote in the preamble of the
document below

\makeatletter
\newcommand{\myhref}[2]{\hyper@linkurl{#2}{#1}}
\makeatother

and replaced "\href" in the document with "\myhref". However, I do
not feel very comfortable (or competent in) using hyperref's internal
commands.

(1) Is this a reasonable solution, or
(2) have I overlooked an equivalent command already available in the
hyperref package?


Dwynn

-------------------------------------

"L. Dwynn Lafleur" <laf...@louisiana.edu> wrote in message news:<-_qdnYQCquC6...@centurytel.net>...

0 new messages