[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#287309: tetex-bin: example using html \special is a bit off



Your example:

  \documentclass{article}
  \usepackage{hyperref}
  \begin{document}
  \special{html:<a href="#paradise">}Paradiselink\special{html:</a>}
  \newpage
  \special{html:<a name="paradise">}Paradise\special{html:</a>}
  \end{document}

has a slight problem because # is a special character for tex/latex.
The output of your 'strings' command shows the problem:

   html:<a href="##paradise">

So latex tried to be smart and replaced # with two of them, which
explains the "Anchor ##paradise not found" error.  For me the following
worked (using plain TeX, since I don't know anything about latex):

{\catcode`\#=11%
\global\def\numbersign{#}}
Here is a forward reference to the next page:
\special{html:<a href="\numbersign paradise">}Paradiselink\special{html:</a>}.
\vfill\eject
\special{html:<a name="paradise">}Paradise\special{html:</a>}
\end

The HyperTeX FAQ <http://arxiv.org/hypertex/> is quite useful, and is
where I found the catcode trick:

  If you want to use a fragment indicator in the URL (the `#' hash mark),
  make sure to change its catcode to `letter' first:

  {\catcode`\#=11
  \special{html:<a href="http://www.foo.org/bar#foobar"}}

  See chapter 7 of the TeXbook for more information about catcodes.
          
As that FAQ says a bit later, all that \catcode and \special nastiness
is best done by a macro package (e.g. hyperbasics.tex available from
arxiv.org).

-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   - Bertrand de Jouvenal



Reply to: