4

I seem to have a problem with hyperreflinks in rotated TikZ nodes: This code

\documentclass{article}
\usepackage{hyperref}

\usepackage{tikz}

\begin{document}
  \section{Testsection\label{sec:test}}

  \begin{tikzpicture}
    \node at (0,0) [draw=blue] {Unrotated node: see Sec.~\ref{sec:test} on p.~\pageref{sec:test}};
    \node at (5,0) [draw=green,rotate=90] {Rotated node: see     Sec.~\ref{sec:test} on p.~\pageref{sec:test}};
  \end{tikzpicture}

\end{document}

leads to the following output:

hyperlinks in (un)rotated nodes

The problem is that the hyperlinks for the \ref's in the rotated node appear at the unrotated position. Answers to another question (Wrong place for hyperref link in scaled tikz picture) suggested wrapping the whole tikzpicture in a \rotatebox, which doesn't directly work here since I have both rotated an unrotated nodes. Also, the \refs appear in several larger tikzpictures which would be a pain to rearrange.

Is there some way to solve/circumvent the problem?

3
  • BTW, hyperref likes to be loaded last (although that doesn't appear to be the problem here). May 3, 2016 at 14:09
  • FWIW, xelatex or tectonic work out of the box for your example.
    – BlackShift
    Mar 24, 2021 at 13:16
  • Not in lualatex though :/ Sep 1, 2022 at 10:50

1 Answer 1

2

Rotating an individual node seems to work, partially; the bounding box of the picture does not work well. (Based on John Kormlyo comment) Rotating inside node seems to work.

enter image description here

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

\begin{document}
  \section{Test section\label{sec:test}}

\begin{tikzpicture}
    \node at (0,5) [draw=blue] {Unrotated node: see Sec.~\ref{sec:test} on p.~\pageref{sec:test}};
    \node at (5,5) [draw=green] {\rotatebox{90}{Rotated node: see {Sec.~\ref{sec:test}} on p.~\pageref{sec:test}    }};
  \end{tikzpicture}

\end{document}
1
  • 1
    Putting \rotatebox inside the node works better. May 3, 2016 at 14:05

You must log in to answer this question.

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