[texhax] Hyperlinks in plain TeX

David Carlisle d.p.carlisle at gmail.com
Thu Jun 9 15:25:36 CEST 2016

On 9 June 2016 at 14:07, Rodolfo Medina <rodolfo.medina at gmail.com> wrote:

> Hi to all (La)TeX users.
> Here:
> http://tex.stackexchange.com/questions/85148/plain-tex-and-different-hyperlink-styles-in-dvi-and-pdf
> there are some macros (written by Alan U. Kennington) about how to produce
> hyperlinks and cross-reference-hyperlinks in plain TeX.  I tested them but
> for
> me the link disappears when I convert the dvi format to pdf with: `dvips -z
> file.dvi' and then `ps2pdf file.ps'.  Here is my simple example:

Isn't this identical to the hyperbasics question just asked?

as it says at the top of the hyperbasics.tex file the \specials
are inserted in the format required by specific dvi drivers so you have to
one of those (dvips isn't listed) or edit the file to use specials
understood by dvips.

hyperbasics is very old, most supported files (such as hyperref) that do
this sort of thing have existing options to write out the \specials or
\pdfliteral required for different workflows
is there any particular reason to use this package?

If you want to make it work you just need to update the specials, eg for
the end of a link

hyperref has in hyperdef.def

\def\hyper at anchorend{%
  \Hy at activeanchorfalse
  \Hy at RestoreLastskip

which is the special syntax you are using, and in hdvips.def (inputting

\def\hyper at anchorend{%
  \literalps at out{\strip at pt@and at otherjunk\baselineskip\space H.A}%
    View=/\@pdfview \@pdfviewparams,%
    DestAnchor=\hyper at currentanchor,%
  \Hy at activeanchorfalse
  \Hy at RestoreLastskip

where \pdfmark is defined to use this special

\def\literalps at out#1{\special{ps:SDict begin #1 end}}%

and the pdfmark operator (see \def\pdfmark in pdfmark.def)


> % This \PreHatch macro to prefix a text string with a hatch character.
> {\catcode`\^=6 \catcode`\#=12 \gdef\PreHatch^1{#^1}}
> % Anchor points for cross-reference hyperlinks.
> \def\LinkNameText#1#2{%
>  \special{html:<a name="#1">}#2\special{html:</a>}}
> \def\LinkNamePRE#1{\special{html:<a name="#1">}}
> \def\LinkNamePOST{\special{html:</a>}}
> \def\LinkName#1{\LinkNameText{#1}{}}
> % Cross-reference hyperlinks to defined anchor points.
> \def\LinkHrefText#1#2{%
>  \special{html:<a href="\PreHatch{#1}">}#2\special{html:</a>}}
> % Pre-text and post-text macros.
> \def\LinkHrefPRE#1{\special{html:<a href="\PreHatch{#1}">}}
> \def\LinkHrefPOST{\special{html:</a>}}
> % External hyperlinks.
> \def\LinkHrefExtText#1#2{%
>  \special{html:<a href="#1">}#2\special{html:</a>}}
> \def\LinkHrefExt#1{\LinkHrefExtText{#1}{#1}}
> \def\LinkHrefExtTT#1{\LinkHrefExtText{#1}{{\tt#1}}}
> hallo\LinkName{label}
> \LinkHrefText{label}{please click here}
> \end
> , to be processed with simply `tex file'.  The link works fine in dvi
> format
> but, as I said, it is no more there after `dvips -z -> ps2pdf' conversion.
> Please help whoever can.
> Thanks,
> Rodolfo
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20160609/6e5e90d0/attachment-0001.html>

More information about the texhax mailing list