Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to make a small mindmap such that some of the child nodes are hyperlinked. I tried to follow the advice given here, about the new node style hyperlink node, but the following MWE compiles with errors.

Just to clarify the structure of the MWE, it first defines the hyperlink node style, which is then subsequently used in the line

  node[concept, hyperlink node=www.google.com] {practical}

Here is the MWE (which is adapted from here):

\documentclass{article}
\usepackage[hidelinks]{hyperref}

\usepackage{tikz}
\usetikzlibrary{mindmap,trees}

\begin{document}
\pagestyle{empty}
\tikzset{
    hyperlink node/.style={
        alias=sourcenode,
        append after command={
            let     \p1 = (sourcenode.north west),
                \p2=(sourcenode.south east),
                \n1={\x2-\x1},
                \n2={\y1-\y2} in
            node [inner sep=0pt, outer sep=0pt,anchor=north west,at=(\p1)] {\hyperlink{#1}{\phantom{\rule{\n1}{\n2}}}}
        }
    }
}
\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Computer Science}
    [clockwise from=0]
    child[concept color=green!50!black] {
      node[concept, hyperlink node=www.google.com] {practical}
      [clockwise from=90]
      child { node[concept] {algorithms} }
      child { node[concept] {data structures} }
      child { node[concept] {pro\-gramming languages} }
      child { node[concept] {software engineer\-ing} }
    }  
    child[concept color=blue] {
      node[concept] {applied}
      [clockwise from=-30]
      child { node[concept] {databases} }
      child { node[concept] {WWW} }
    }
    child[concept color=red] { node[concept] {technical} }
    child[concept color=orange] { node[concept] {theoretical} };
\end{tikzpicture}\end{document}

Any advice on how to make mindmaps in TikZ hyperlinkable or help fixing this solution would be appreciated.

share|improve this question
    
You’ll need at least the calc library for let … in. –  Qrrbrbirlbel Jan 7 '13 at 9:31
    
@Qrrbrbirlbel Thanks. I added \usetikzlibrary{calc}. –  fg nu Jan 7 '13 at 9:36
add comment

2 Answers

up vote 6 down vote accepted

The quickest fix is to put directly inside the node the \hyperlink, for example:

node[concept] {\hyperlink{pract}{practical}}

This won't alter the appearance of the concept style.

The code:

\documentclass{article}
\usepackage[hidelinks]{hyperref}

\usepackage{tikz}
\usetikzlibrary{mindmap}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Computer Science}
    [clockwise from=0]
    child[concept color=green!50!black] {
      node[concept] {\hyperlink{pract}{practical}}
      [clockwise from=90]
      child { node[concept] {algorithms} }
      child { node[concept] {data structures} }
      child { node[concept] {pro\-gramming languages} }
      child { node[concept] {software engineer\-ing} }
    }  
    child[concept color=blue] {
      node[concept] {applied}
      [clockwise from=-30]
      child { node[concept] {\hyperlink{datab}{databases}} }
      child { node[concept] {WWW} }
    }
    child[concept color=red] { node[concept] {technical} }
    child[concept color=orange] { node[concept] {theoretical} 
    };
\end{tikzpicture}
\newpage
\begin{itemize}
\item \hypertarget{pract}{Practical}: here is some description.
\item \hypertarget{datab}{Databases}: here is some description.
\end{itemize}
\end{document}
share|improve this answer
    
I guess this means that the whole node is not clickable? –  fg nu Jan 7 '13 at 9:42
    
Yes, with this approach just the text is clickable. –  Claudio Fiandrino Jan 7 '13 at 9:43
    
Ok, I will wait for a little while for someone to come along with a way to make the whole node clickable as in the hyperlink node style, else I will mark your answer. Thanks. –  fg nu Jan 7 '13 at 9:45
    
@fgnu: I've actually investigated a bit the problem, but I didn't came up with a reasonable answer. I started in chat a discussion: the code there actually makes the node completely clickable, but it still generates the same errors of the question. –  Claudio Fiandrino Jan 7 '13 at 10:41
    
Many thanks for your efforts. I will keep an eye on the chat threads as well. I hope you are able to find a solution. :) –  fg nu Jan 7 '13 at 12:16
add comment

In this solution, I use path picture instead of append after command.

(Note: the hyperlink is always a rectangular area...)

\documentclass{article}
\usepackage[hidelinks]{hyperref}

\usepackage{tikz}
\usetikzlibrary{mindmap,trees,calc}

\begin{document}
\pagestyle{empty}
\tikzset{
    hyperlink node/.style={
      postaction={
        path picture={
          \path let
          \p1 = (path picture bounding box.south west),
          \p2 = (path picture bounding box.north east),
          \p3 = (\x2-\x1,\y2-\y1)
          in
          (path picture bounding box.center)
          node[inner sep=0pt,anchor=center,outer sep=0pt]
          {\hyperlink{#1}{\phantom{\rule{\x3}{\y3}}}};
        }
      },
    },
}
\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Computer Science}
    [clockwise from=0]
    child[concept color=green!50!black] {
      node[concept, hyperlink node=www.google.com] {practical}
      [clockwise from=90]
      child { node[concept] {algorithms} }
      child { node[concept] {data structures} }
      child { node[concept] {pro\-gramming languages} }
      child { node[concept] {software engineer\-ing} }
    }  
    child[concept color=blue] {
      node[concept] {applied}
      [clockwise from=-30]
      child { node[concept] {databases} }
      child { node[concept] {WWW} }
    }
    child[concept color=red] { node[concept] {technical} }
    child[concept color=orange] { node[concept] {theoretical} };
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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