[OS X TeX] Hyperlink failure with TeXShop and Preview

Peter Dyballa Peter_Dyballa at Web.DE
Sun Feb 11 01:11:56 CET 2007


Am 10.02.2007 um 22:16 schrieb Bruno Voisin:

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

Using TeXShop or Preview I can clearly see the floating hint. Your  
macro does not produce it, because of the use of invalid characters –  
a "correct malfunction" in hyperref! I first misinterpreted this  
behaviour, and actually I did not click any URL, I believed what I  
saw printed and floating.

And your observation does not seem to be right: clicking a correct  
URL with <>; converted to HEX or hex is forwarded to the browser, for  
example:

	\href{http://dx.doi.org/10.1002/1099-095X(200102)12:1%3c57::AID- 
ENV446%3e3.0.CO%3b2-1}{DOI:10.1002/1099-095X(200102)12:1<57::AID- 
ENV446>3.0.CO;2-1}
	\doi{10.1002/1099-095X(200102)12:1\%3C57::AID-ENV446\%3E3.0.CO\%3B2-1}

which also works with HEX translation. Did you translate ``;´´ too?

>
> I don't think that hyperref performs any such conversion currently.  
> Or did I miss something?

Yes, you're right: the regular code in the hyperref package obviously  
does not provide the conversion. Again, I misunderstood that the  
first part of \href{one}{two} is the text that is shown in the  
floating hint (and executed by clicking at it) and the second part is  
actually printed in the document – I should have tried earlier the  
successful URLs above instead of hoping that some combination might  
work!

> 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}}

It does not seem to work completely like this. The url package sets  
the URL in a monospaced font. Could be this side-effect is left from  
hyperref's then incomplete renewal.

The difference is obvious in the PDF file. \href{one}{two} or \doi 
{one} create:

	25 0 obj <<
	/Type /Annot
	/Border[0 0 0]/H/I/C[0 1 1]
	/Rect [44.287 118.034 434.951 129.555]
	/Subtype/Link/A<</Type/Action/S/URI/URI(one)>>
	>> endobj

which simply works, \href{one}{\url{two}} creates with or without the  
url package:

	26 0 obj <<
	/Type /Annot
	/Border[0 0 0]/H/I/C[0 1 1]
	/Rect [44.287 90.935 434.951 102.124]
	/Subtype/Link/A<</Type/Action/S/URI/URI(one)>>
	>> endobj
	27 0 obj <<
	/Type /Annot
	/Border[0 0 0]/H/I/C[0 1 1]
	/Rect [44.287 90.935 434.951 102.124]
	/Subtype/Link/A<</Type/Action/S/URI/URI(two)>>
	>> endobj

so the second argument is recorded as another URL via \url, but since  
its definition is wrong (either by starting with DOI or having faulty  
characters) this faulty value substitutes/overwrites the correct  
definition. So clicking does not effect anything.

--
Greetings

   Pete

If you're not confused, you're not paying attention.



------------------------- 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 macostex-archives mailing list