[OS X TeX] Hyperlink failure with TeXShop and Preview

Bruno Voisin bvoisin at mac.com
Sat Feb 10 16:16:34 EST 2007


Le 10 févr. 07 à 18:01, Peter Dyballa a écrit :

> I played a bit with hyperref and this particular URL.
>
> 	\href{http://dx.doi.org/10.1002/1099-095X(200102)12:1%3c57::AID- 
> ENV446%3e3.0.CO%3b2-1}{\url{http://dx.doi.org/10.1002/1099-095X 
> (200102)12:1<57::AID-ENV446>3.0.CO;2-1}}
>
> works fine and so does
>
> 	\href{http://dx.doi.org/10.1002/1099-095X(200102)12:1<57::AID- 
> ENV446>3.0.CO;2-1}{\url{http://dx.doi.org/10.1002/1099-095X(200102) 
> 12:1<57::AID-ENV446>3.0.CO;2-1}}
>
> because hyperref translates the inappropriate characters into  
> correctly escaped ones.
>
> In my understanding your new command \doi{url} would expand to
>
> 	\href{http://dx.doi.org/url}{DOI:url}
>
> giving a floating hint of “DOI:url” for the reader, I mean that  
> supposedly human person. But this does not work. It seems that the  
> definition of \newcommand inhibits the complete effect of \href ...  
> look inside the PDF!

Pete,

I don't quite get what you mean. Writing

\newcommand{\doi}[1]{\href{http://dx.doi.org/#1}{DOI:#1}}

does work, it produces in the PDF output the text "DOI:#1" and makes  
that text a link of target "http://dx.doi.org/#1", which was exactly  
the desired effect.

The only problem is when the DOI contains the characters "<" and  
">" (and probably "#", and other such characters as well): clicking  
on the link in Adobe Reader opens the proper URL in the default web  
browser, because Reader converts "<" to "%3C" internally, and ">" to  
"%3F", before passing on the URL to the browser. However, in Preview  
and TeXShop the same not happen, because apparently the Apple  
frameworks they both use do not perform the same conversion, and  
clicking on the link has no effect.

The code that Heiko Oberdiek has posted in comp.text.tex performs the  
conversion beforehand, namely it makes "<" active and  converts it to  
"%3C" in the first argument of \href and to \textless in the second  
argument, and similarly for ">" and "#".

I don't think that hyperref performs any such conversion currently.  
Or did I miss something? I'm also puzzled by your use of \url inside  
\href: I thought that \url was redefined by hyperref to work  
essentially as

\renewcommand{\url}[1]{\href{#1}{#1}}

Bruno
------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the MacOSX-TeX mailing list