[OS X TeX] Underlined links with hyperref

Bruno Voisin bvoisin at mac.com
Sun Mar 20 10:33:14 EST 2005

Le 20 mars 05, à 15:24, Thomas Schröder a écrit :

> I'm preparing my thesis with pdflatex and the hyperref package. As  
> many others, I'm not very fond of the rectangle around  hyperlinks  
> when previewing the resulting pdf in Adobe Reader and I'd rather have  
> them underlined. I've been doing some googling and learned that the  
> rectangle is produced by Adobe Reader and that there's nothing you can  
> do about it, really. But then I came across this posting
> http://groups.google.com/groups?hl=de&lr=&client=safari&rls=de- 
> de&selm=991919386.946568%40newsmaster-04.atnet.at
> which is in German and says that the PDF specifications state that  
> there are also other styles next to the boxed style, specifically an  
> underlined style, but that this person couldn't do it, not even in low  
> level PDF.
> [...]
> Therefore, after making a backup of course :-), I changed  
> hpdftex.def's definition of all of its /Border commands from
> /Border[\@pdfborder]%
> to
> /Border[\@pdfborder]/BS<</W 1/Type/Border/S/U>>%
> And low and behold! I get nicely underlined links in my pdf!
> [...]
> I thought some of you might like this, too so, here it is. I don't  
> really know if this is really correct and all, but if nobody finds a  
> really bad error maybe I should get back to Heiko Oberdiek, the  
> original author of hyperref, so he might work this in to make it an  
> option in future releases? What do you guys think?

Sure this would be a nice option to have. About a year ago I asked this  
here, and in comp.text.tex. From the few answers I got at  
comp.text.tex, I got the impression the community wasn't really  
interested and that the common opinion was that hyperlinks in TeX text  
should be either boxed or colored, preferably not underlined. See  
g.google.com%26rnum%3D3>. According to a link in this thread  
comp.text.tex&hl=en&lr=&ie=UTF-8&rnum=2>, Heiko Oberdiek seems to not  
be aware that hyperlinks can be underlined in Acrobat.

Thus I ended up using the ulem.sty package to get underlining, and  
redefining the hyperref commands that produce hyperlinks, to have them  


	\renewcommand{\url@}[1]{\hyper at linkurl{\uline{\Hurl{#1}}}{#1}}
	\renewcommand{\hyper at link@}[4][]
	  {\protected at edef\Hy at tempa{#2}%
	   \ifthenelse{\equal{\Hy at tempa}{\@empty}}
	     {\hyper at link{#1}{#3}{\uline{#4}}}
	     {\expandafter\hyper at readexternallink#2\\{#1}{#3}{\uline{#4}}}}
	     {\csname l@#1\endcsname{#2}{#3}}
	     {\ifthenelse{\boolean{Hy at linktocpage}}
	        {\csname l@#1\endcsname
	           {\hyper at linkstart{link}{#4}{\uline{#3}}\hyper at linkend}}
  	       {\csname l@#1\endcsname
  	          {\hyper at linkstart{link}{#4}{\uline{#2}}\hyper at linkend}

That may not work as is right now, as hyperref.sty and url.sty may have  
changed since last year.

In any case your solution is much more elegant and robust. The only  
issue is to implement this function in all driver files (hpdftex.def,  
hdvips.def, etc.) as an option to hyperref.sty, similar to colorlinks  
or frenchlinks.

Bruno Voisin
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>

More information about the MacOSX-TeX mailing list