Hi to all (La)TeX people


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.
 \special{html:<a name="#1">}#2\special{html:</a>}}
\def\LinkNamePRE#1{\special{html:<a name="#1">}}

% Cross-reference hyperlinks to defined anchor points.
 \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}">}}

% External hyperlinks.
 \special{html:<a href="#1">}#2\special{html:</a>}}

% then my simple test:

\LinkHrefText{label}{please click here}


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.

  • Welcome to TeX.SX! As far as I remember, eplain has support for hyperlinks
    – egreg
    Commented Jun 10, 2016 at 11:24
  • Yes, I know, and use them regularly and they work fine, but here I was just curious to see how so few lines of code can build hyperlinks in plain TeX, and how they work. Commented Jun 10, 2016 at 11:31
  • 1
    They are built also in OPmac, in few lines of code
    – User
    Commented Jun 10, 2016 at 12:27
  • in order to generate the pdf output I need the dvips -> ps2pdf process, whereas, as far as I know, OPmac requires pdftex Commented Jun 10, 2016 at 12:35
  • 1
    yes, in some documents of mine: tho ones with MusiXTeX code. In fact MusiXTeX may in particular cases use special ps features Commented Jun 10, 2016 at 13:33

1 Answer 1


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.

  • But the thread I mentioned above was just about hyperlinks generated in dvips -> ps2pdf mode. And those hyperlinks macros written by Alan U. Kennington's in that thread do not seem work with pdftex either. Commented Jun 10, 2016 at 13:40
  • @RodolfoMedina I wrote about dvips -> ps2pdf mode, no about pdfTeX (except the last recommendation). Now, I have found the problem, see the Edit part of my answer.
    – wipet
    Commented Jun 10, 2016 at 14:34
  • Fantastic!! many many thanks. Now it works in both dvi and pdf format. Commented Jun 10, 2016 at 14:42
  • I want now to use external hyperlinks with those macros. But the command \LinkHrefExtText seems to always point to the first page of target file. Do you maybe understand if, using those macros, it is possibile to point to a desired labeled point of target file? I don't manage to. Thanks Commented Jun 10, 2016 at 21:59
  • 2
    @RodolfoMedina Aha, there is undocumented feature. If the href string begins with "file:" then it works. More precisely, suppose that your destination PDF has name foo.pdf and destination point is labeled by label. Then you can create external link as \special{html:<a href="file:foo.pdf\string#label">}klick here\special{html:</a>}.
    – wipet
    Commented Jun 13, 2016 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .