2

I use the sloped option to place slanted nodes along arrows in tikz. Now if that text contains clickable references with the hyperref package, they are not sloped. The text and the link are not aligned. Is there any way to rotate them too? Is this a bug in tikz?

These answers here don't help because I don't know the angle of rotation. It is computed by tikz.

Here is the minimal non working example for me:

\section{abc}\label{s:a}
One section
\section{def}\label{s:b}
Another section

\begin{tikzpicture}
  \node[rectangle, fill] (one) {} ;
  \node[rectangle, fill, right=5cm of one,yshift=3cm] (two) {};
  \path (one) edge[-,bend right=-31, near start] node[sloped,above] {\ref{s:a}~~~\ref{s:b}} (two);
\end{tikzpicture}

Result: The link for the two sits below the two, because the linkbox is not sloped.

  • 3
    Could you edit your question to include the code for a small example document that demonstrates the issue? – Jake May 27 '14 at 9:42
3

Don't use sloped and above but rotation and shifting instead, because the problem comes with it.

Edit : with one unique command :

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
%\usepackage[colorlinks]{hyperref}
\usetikzlibrary{calc}


\makeatletter
\newcommand{\Hyp}[4][.5]{%
    \draw #2 -- #3
    let \p1 = ($ #3 - #2 $)
        in 
    \pgfextra{%
        \pgfmathparse{90-atan2(\x1,\y1)}
        \xdef\@ngle{\pgfmathresult}
    }
    node[pos=#1,shift={(\@ngle+90:8pt)}]
              {\rotatebox{\@ngle}{#4}}
    }
\makeatother

\begin{document}


\section{abc}\label{s:a}
One section
\section{def}\label{s:b}
Another section

\begin{tikzpicture}
\node[fill] (A) at (0,0)  {} ;
\node[fill] (B) at (50:4) {}  ;
\node[fill] (C) at (150:6) {}  ;

\Hyp{(A)}{(B)}{\ref{s:a}~~~\ref{s:b}} ;
\Hyp{(C)}{(A)}{\ref{s:a}~~~\ref{s:b}} ;

\end{tikzpicture}
\end{document}
  • I'm on the run, but what happens if you have two or more hyperrefs in your node? – Thomas May 27 '14 at 12:34
  • See my new answer. – Tarass May 27 '14 at 14:04
  • @Thomas still running ? ;-) is the answer convinient ? – Tarass May 28 '14 at 18:46
  • Thanks for your answers, but they more or less replicate what was in the answers I already linked. See my new example. – Thomas May 30 '14 at 6:45
  • I updated my answer, don't use sloped. One can make a newcommand to avoid repetitive command. – Tarass May 30 '14 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.