# [XeTeX] Hyperref support in XeLaTeX

Jonathan Kew jonathan_kew at sil.org
Tue Oct 4 13:39:46 CEST 2005

Hi Bruno,

On 4 Oct 2005, at 12:20 pm, Bruno Voisin wrote:

> I've been trying to use XeLaTeX to write a document requiring
>
> According to XeTeX-notes.tex, the hyperref package together with
> the dvipdfm option should allow this, at least partly. Hence I used:
>
> \usepackage[dvipdfm,
>             pdfstartview=FitH]{hyperref}
>
> However, doing that I've noticed:
>
> - The bookmarks, either created automatically by \section etc. or
> added manually via \label and \ref, work as expected in Adobe
> Reader but don't work in Preview or in TeXShop's preview window.

Yes, I'm aware of this. It seems that Apple's PDF viewer doesn't
support all the potential ways of specifying link targets, and the
format that xdv2pdf currently uses doesn't work there. :( Very annoying.

(An ambitious PDF hacker could try to rewrite the xdv2pdf_mergemarks
script (typically installed in /usr/local/teTeX/bin/powerpc-apple-
darwin-current/xdv2pdf_mergemarks), which is what actually adds the
hyperref elements to XeTeX PDFs. It's just a Perl script.)

> - Making an included graphics a hyperlink doesn't seem to work: the
> linked area has the whole width and height of the page, and is
> displaced with respect to the upper left corner of this page, as
> linked area appears black). I tried several possibilities:
>
> \href{http://www.legi.hmg.inpg.fr/}{\includegraphics[width=200pt]
> {LogoLegiPantone}}
>
> \href{http://www.legi.hmg.inpg.fr/}{\resizebox{200pt}{!}
> {\includegraphics{LogoLegiPantone}}}
>
> \resizebox{200pt}{!}{\href{http://www.legi.hmg.inpg.fr/}
> {\includegraphics{LogoLegiPantone}}}
>
> but that doesn't make any difference. The included graphic is a PDF
> file LogoLegiPantone.pdf. Not resizing it doesn't make a difference
> either.

Don't think I've ever tried this; but it sounds like a bug.

On thinking about it, I'm not surprised; the driver is trying to
figure out the area of the link based on the glyphs that are rendered
between the \special{}s for the start and end of the link--but there
aren't any, if all you have is an image. It needs to remember to also
look at images (and rules--I think you'd have the same problem if you
tried to turn a TeX rule into a link).

You could possibly hack around this by wrapping your graphic
inclusion in a macro that outputs glyphs at two diagonally opposite
corners of the image; they could be small blank glyphs (e.g.,
\char32), so as not to show on the page, as long as they're real
glyphs in a font so that xdv2pdf "sees" them. I think that would
trick the driver into creating the proper link area.

JK