[OS X TeX] OT: setting the look of hyperlinks with hyperref

Bruno Voisin bvoisin at mac.com
Mon Mar 29 15:46:40 CEST 2004


Le 29 mars 04, à 14:59, Bob Kerstetter a écrit :

> On Mar 29, 2004, at 5:02 AM, Bruno Voisin wrote:
>
>> Also, "my" solution also breaks the ability (I'm working in pdfTeX) 
>> of hyperlinks to be broken across several lines, so it's definitely 
>> sub-optimal.
>
> Hi Bruno,
>
> Maybe I am missing your point here, but this both underlines and wraps 
> and makes a working hyperlink in 10.3's Preview. Requires the ulem 
> package. I got the \newcommand{\cuuline} from someone else, maybe the 
> author of ulem. I don't remember.  It's a double underline, but I just 
> define one color as "white" to make it a single underline.
>
> \documentclass{article}
> \usepackage{color}  % << color package is required
> \usepackage{ulem} % << ulem package is required
>
> %red over blue double under line-- swap red and blue in second line to 
> make it blue over red
> \newcommand{\cuuline}{\bgroup\markoverwith{\hbox{\kern-.03em\vtop%
> {\begingroup\kern.2ex\color{blue}\hrule width.2em\kern1.1pt\color{red}%
> \hrule\endgroup\kern-.03em}}}\ULon}
>
> \usepackage[colorlinks=true]{hyperref} %goes last to redefine the 
> world.
>
> \begin{document}
>
> %this is asample of the command in use
>
> Steve Jobs says,  ``I think 
> \href{ht½0V£/www.apple.com}{\cuuline{different.}}''.
>
> \end{document}

Hi Bob,

Thanks for the tip about the ulem package. What I was looking for was a 
way to set options for the hyperref package, such that

	\href{http://www.apple.com}{different.}

colors, underlines, wraps if required, and makes a working hyperlink of 
"different", without having to specify \underline, \uline or \cuuline 
explicitly. Also, I was looking for a solution that works for \url too, 
namely for:

	\url{http://www.apple.com}

coloring, underlining, wrapping if required, and making a working 
hyperlink of "http://www.apple.com".

Finally it seems that the ulem package can be used for patching the 
commands of hyperref.sty; this surprises me slightly given the 
relatively low-level of these commands. What seems to work (stripping 
out all unnecessary packages and options):

\documentclass{article}
\usepackage{color}
\usepackage[normalem]{ulem}
\usepackage[colorlinks=true]{hyperref}

% Now we redefine certain commands of hyperref.sty
%
\makeatletter
% The following for \url
\def\url@#1{\hyper at linkurl{\uline{\Hurl{#1}}}{#1}}
% The following for \href
\def\hyper at link@[#1]#2#3#4{%
   \protected at edef\Hy at tempa{#2}%
   \ifx\Hy at tempa\@empty
     \hyper at link{#1}{#3}{\uline{#4}}%
   \else
     \expandafter\hyper at readexternallink#2\\{#1}{#3}{\uline{#4}}%
   \fi
}
\makeatother

Bruno
-----------------------------------------------------
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the macostex-archives mailing list