8

Possible Duplicate:
Making TikZ nodes hyperlinkable

something that has been giving me trouble for some time now. I would like to attribute a hyperlink to a shape, that is, not to text but to a whole area. For eg. in the MWE below, I would like the whole of the green circle to react as the mouse is positioned on top of it.

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

\begin{document}

\begin{tikzpicture}
\node[circle, draw=black, fill=red!20, minimum size=2cm] (c1) {\hyperlink{t1}{long text}};
\node[circle, draw=black, fill=red!20, minimum size=2cm, right= 3cm of c1] (c1) {\hyperlink{t1}{}};
\end{tikzpicture}

\newpage

\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}

\end{document}

Any idea? Thanks

jejuba
  • 1,471
  • 2
  • 13
  • 21
  • @Jake In my solution, it's not the node the hyperlink but the box. It's only possible if the shape is a rectangle. Is it possible with your solution with a circle? – Alain Matthes Jun 18 '12 at 21:36
  • @Altermundus: In my solution, the clickable area with a circle node is too small, in yours it's too big =) – Jake Jun 18 '12 at 21:45

1 Answers1

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

\begin{document}

\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm] (c1) {long text};}

\newpage

\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}

\end{document} 

Possible nested tikzpictures

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
 \usetikzlibrary{positioning}       
\begin{document}

\begin{tikzpicture}
 \node (c1) {\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm]  {long text};}};  
 \node[right= 3cm of c1] (c2) {\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm]  {};}};  
\end{tikzpicture}


\newpage

\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}

\end{document}
Alain Matthes
  • 95,075