[Tex/LaTex] Hyperlinks in plain TeX

plain-tex

Hi to all (La)TeX people

Here:

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:

% first Alan U. Kennington's macros:
%
% 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}}}


% then my simple test:
%
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.

Best Answer

I am not sure, but IMHO the way dvips -z which converts hypertext-html specials to pdfmark does not work because it is unsupported now. The hyperref package for LaTeX does not use the hypertext-html specials when the way LaTeX -> dvi -> dvips -> ps2pdf is used. It uses its own complicated solution with much more and large specials: they generate the pdfmark language directly.

My supposition is based on the fact that nobody uses hypertex-html specials when the way dvi -> PS -> PDF is used, so they are unsupported. Of course, they are documented at a very old www page and they are working in xdvi previewer.

I recommend not to use tex -> dvi -> dvips -> PS -> ps2pdf way because today we have much more simple methods to generate PDF.

Edit I have found the core of the bug. If the link starts in vertical mode and ends in the first line of paragraph in horizontal mode (like in your example), then the sensitive rectangular array of the link disappears. Try to use Hey, \LinkHrefText{label}{please click here} instead of only \LinkHrefText{label}{please click here}. Or prefix your link by \leavevmode.

Related Question