# TikZ: connecting nodeparts

I'm new to TikZ. Last couple of hours in fact.

I was wondering if there was a way of connecting nodeparts from different nodes.

Here's an example

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}

\begin{tikzpicture}[
grow=right,
level 1/.style={sibling distance=3.5cm,level distance=5.2cm},
edge from parent/.style={draw=white},
]

\node[name=block1, rectangle split, rectangle split parts=4, draw=black]
{ \textbf{Block 1}
\nodepart{second} connect to a
\nodepart{third} connect to b
\nodepart{fourth} connect to c
}
child {
node[name=block2, rectangle split, rectangle split parts=4, draw=black]
{  \textbf{Block 2}
\nodepart{second} \Huge{a}
\nodepart{third} \Huge{b}
\nodepart{fourth} \Huge{c}
}
};
\end{tikzpicture}
\end{document}


I want to connect the nodeparts of block 1 to 2. I was hoping I could do something like:

\draw [->] (block1.second.east) -- (block2.second.west);


...but alas, it did not work, and I couldn't figure out how to do this.

(I guess I could just stack plain nodes and connect them as per usual, but still interested in a solution here.)

-
You are almost there. Just remove the second set of dots : \draw [->] (block1.second east) -- (block2.second west); –  percusse Nov 24 '11 at 2:41
Hehe. Thanks! (My hopes for TikZ are restored!) –  badroit Nov 24 '11 at 2:44

The multipart nodes have anchors called <node name>.one, <node name>.two east, etc., that allow you to reference the individual parts. The anchors for the rectangle split node are shown in the section Shapes with Multiple Text Parts of the pgfmanual. As percusse points out in the comment on the question, the node parts can also be referenced using .second, .third, etc., although this is not documented in the manual.

As a side note, for positioning your nodes in this case, I would not use a tree but rather the positioning library, which introduces the syntax right = of <node name> to place new nodes.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\begin{document}

\begin{tikzpicture}

\node[name=block, rectangle split, rectangle split parts=4, draw]
{ \textbf{Block 1}
\nodepart{second} connect to a
\nodepart{third} connect to b
\nodepart{fourth} connect to c
};

\node[name=block2, rectangle split, rectangle split parts=4, draw, right= of block]
{  \textbf{Block 2}
\nodepart{second} \Huge{a}
\nodepart{third} \Huge{b}
\nodepart{fourth} \Huge{c}
};
\draw [-latex] (block.two east) -- (block2.two west);
\draw [-latex] (block.three east) -- (block2.three west);
\draw [-latex] (block.four east) -- (block2.four west);
\end{tikzpicture}
\end{document}

-