[pdftex] Creating hyperlinks in plain pdftex.
John R. Culleton
john at wexfordpress.com
Sat Mar 25 19:29:23 CET 2006
On Thursday 23 March 2006 15:34, Jim Diamond wrote:
> 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 ??
> >> \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
> >
> > 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.,
> > \href{http://snipurl.com/nv6p}{PRLeads} so I would need to add a #2
> > to your macro.
>
> 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
> _______________________________________________
> pdftex mailing list
> pdftex at tug.org
> http://tug.org/mailman/listinfo/pdftex
Aha! so you diss LaTeX (nothing wrong with that) but use a
LaTeX style to solve the problem. Tch tch.
Hmm. the pdftex program example.tex shows links in color as I recall.
Will have to investigate that issue.
The reason for the switcheroo on URLs is that a former indexing
clent wanted to send people to a particular web page but do it
through a gateway so that he got credit for a click through or
something. However the gateway URL was too long so he wanted to
go though a third site which used short URLs to forward to long
URLs. It was no more pernicious than that. And not my Rube
Goldberg creation but the OP's.
Anyhow he wants to be able to do it himself and he is culturally
limited to MSWord (like so many) so the issue is moot at this point.
--
John Culleton
Books with answers to marketing and publishing questions:
http://wexfordpress.com/tex/shortlist.pdf
Book coaches, consultants and packagers:
http://wexfordpress.com/tex/packagers.pdf
More information about the pdftex
mailing list