2

I'm doing some experiments with \hypertarget and \hyperlink (from hyperref) used inside some TikZ nodes and I noticed an unexpected behaviour.

Please consider the following example code:

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}

\hypertarget{test}{This is the target}

\begin{tikzpicture}
  \node[rotate=90] 
    at (0,0) 
    {\hyperlink{test}{This is the link?}};
  \node 
    at (4cm,0) 
    {\rotatebox{90}{\hyperlink{test}{This is the link}}};
\end{tikzpicture}%

\end{document}

The output:

enter image description here

As you can see, when the rotate option is used to rotate a node and its contents, the hyperlink doesn't get affected; the text rotates but the clickable area remains unaffected. If the rotation is performed using a \rotatebox applied to the node contents, the hyperlink gets transformed appropriately.

I know that this behaviour has been noticed before and some alternatives (included the use of \rotatebox, \adjustbox or making the whole tikzpicture the contents of the hyperlink) have been suggested in the answers to How to rotate hyperlink with text, but I am not interested here in known workarounds; I want to know the reason behind the behaviour and whether or not it is possible to to get the hyperlinks to obey the rotate option for nodes.

Gonzalo Medina
  • 505,128

0 Answers0