latex3 / pdfresources

LaTeX PDF resource management
LaTeX Project Public License v1.3c
22 stars 5 forks source link

Using XeTeX engine, \hyperlink does not work in head and foot. #39

Closed Sophanatprime closed 1 year ago

Sophanatprime commented 1 year ago

MWE:

\DocumentMetadata{}% {backend=xdvipdfmx}
\documentclass{article}
\usepackage{hyperref}

\makeatletter
\def\@oddhead{\hyperlink{foo.anchor.1}{HEAD}\hfil}
\let\@evenhead\@oddhead
\makeatother

\begin{document}

Hello. \hypertarget{foo.anchor.1}{}

\hyperlink{foo.anchor.1}{TEXT}

\end{document}

When using xelatex and \DocumentMetadata, the hyperlink in head does not work. Removing \DocumentMetadata, the code works fine.

log: demo.log

u-fischer commented 1 year ago

The code interrupts links in the header and footer (to avoid that they are part of links broken over pages, see e.g. https://tex.stackexchange.com/a/578405/2388).

You can reenable them like this:

\DocumentMetadata{uncompress}% {backend=xdvipdfmx}
\documentclass{article}
\usepackage{hyperref}

\makeatletter\ExplSyntaxOn
\def\@oddhead{\pdfannot_link_on: \hyperlink{foo.anchor.1}{HEAD} \pdfannot_link_off: \hfil}
\let\@evenhead\@oddhead
\makeatother\ExplSyntaxOff

\begin{document}

Hello. \hypertarget{foo.anchor.1}{}

\hyperlink{foo.anchor.1}{TEXT}

\end{document}
Sophanatprime commented 1 year ago

That's very helpful!