# [pdftex] Creating hyperlinks in plain pdftex.

Thu Mar 23 21:34:28 CET 2006

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

> On Thursday 23 March 2006 14:56, Jim Diamond wrote:
>> 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 ??
>>             % 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}%
>>     \else
>>         % Should we have a special case for tth?
>>         {\tt #1}%
>>     \fi
>>     \endgroup % Reset catcode of ~ and _
>> }

>> Cheers.

>> 				Jim

> I forgot one thing. The actual link and the text in the document may
> not be the same thing.  In other words you click on foo.com but you
> actually get bar.com.
Sounds like one of those techniques used in internet scams :-)

> In LaTeX this is indicated by e.g.,
Quite true.

> Color support?  Are you referring to the pdfcolmlmk package
> mentioned in the manual?
"Package"?  Is that some LaTeX thing??   Blech.

I just meant that my macro uses the \color{} macro, so however you
choose to implement that (or not) is fine with me.  In my case, my use
of \color{} provides the ability for the link to be some color other
than black.  (Essentially, I \input color.sty and \input'ing miniltx.
If the whole story is useful to you, I can send you my related files.)

Cheers.
Jim