[pdftex] Creating hyperlinks in plain pdftex.

Jim Diamond Jim.Diamond at acadiau.ca
Thu Mar 23 20:56:58 CET 2006


On Thu, Mar 23, 2006 at 14:51 (-0500), John R. Culleton wrote:

> The file example.tex describes a verbose way to create a
> hyperlink in a pdf file to an url on the web. pdfLaTeX has a simple 
> \html
> command. 

> Is there a simple way to create the link in plain pdftex?
> Has anyone built a macro that does this? 
> -- 
John,

I use the following, which assumes that you have color support.
Getting color support (or removing it from this def) is left as an
exercise to the diligent student.

% URL support
\def\URLcolor#1{\def\URLcolour{#1}}
\URLcolor{blue}
% Turn off the special meaning of ~ inside \URL{}.
\def\URL{\begingroup\catcode`\~=12\catcode`\_=12\relax\URL@}
\def\URL@ #1{%
    \ifpdf
%       \pdfannotlink user{   pdftex pre 0.14 ??
        \pdfstartlink user{
            /Subtype /Link
            % w/o this you get an ugly box around the URL.
            /Border [ 0 0 0 ]   % radius, radius, line thickness
            /A << 
                /Type /Action 
                /S /URI
                /URI (#1) 
            >>
        }%
        {\color{\URLcolour}\tt #1}%
        \pdfendlink{}%
    \else
        % Should we have a special case for tth?
        {\tt #1}%
    \fi
    \endgroup % Reset catcode of ~ and _
}

Cheers.

				Jim


More information about the pdftex mailing list