3

I would like to draw something like the following:

+-------+
| Alpha |
+-------+      +---------+
| betas |----->| Beta    |
+-------+      +---------+      +--------+
| foo   |      | gammas  |----->| Gamma  |
+-------+      +---------+      +--------+
| bar   |      | foo     |      | deltas |
+-------+      +---------+      +--------+
               | bar     |      | foo    |
               +---------+      +--------+
                                | bar    |
                                +--------+

Actually, it keeps going until Epsilon.

I have the following so far:

\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\begin{document}

\begin{tikzpicture}[%
    mod/.style={%
        draw,%
        rectangle split,rectangle split parts=4,%
        minimum height=3cm,minimum width=2cm}%
]
    \node[mod] (a) {%
        Alpha
        \nodepart{two} betas
        \nodepart{three} foo
        \nodepart{four} bar
    };
    \node[mod,right=of a] (b) {%
        Beta
        \nodepart{two} gammas
        \nodepart{three} foo
        \nodepart{four} bar
    };
    \node[mod,right=of b] (c) {%
        Gamma
        \nodepart{two} deltas
        \nodepart{three} foo
        \nodepart{four} bar
    };
\end{tikzpicture}

\end{document}

which produces the following output:

output of MWE

How could I draw a path from the betas split node part for example? I mean how do I specify that coordinate?

I suppose knowing the answer to the above question would also solve the problem of arranging these nodes the way I showed above.

As a final question: is there an easy way to apply \bfseries to all first node parts? So for Alpha, Beta, and Gamma?

1 Answer 1

3

You can use the anchors two east and text west for both the positioning and the arrows.

\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\begin{document}

\begin{tikzpicture}[>=stealth,%
    mod/.style={%
        draw,%
        rectangle split,rectangle split parts=4,%
        minimum height=3cm,minimum width=2cm}%
]
    \node[mod] (a) {%
        Alpha
        \nodepart{two} betas
        \nodepart{three} foo
        \nodepart{four} bar
    };
    \node[mod,right=of a.two east,anchor=text west] (b) {%
        Beta
        \nodepart{two} gammas
        \nodepart{three} foo
        \nodepart{four} bar
    };
    \node[mod,right=of b.two east,anchor=text west] (c) {%
        Gamma
        \nodepart{two}  deltas
        \nodepart{three} foo
        \nodepart{four} bar
    };
    \draw[->] (a.two east) -- (b.text west);
    \draw[->] (b.two east) -- (c.text west);
\end{tikzpicture}

\end{document}

enter image description here

As for making only the first text bold, I am afraid that there is no super simple solution. You can replace all \nodepart with \nodepart[font=\normalfont] and add font=\bfseries to the definition of the nodes.

\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\begin{document}

\begin{tikzpicture}[>=stealth,%
    mod/.style={%
        draw,%
        font=\bfseries,%
        rectangle split,rectangle split parts=4,%
        minimum height=3cm,minimum width=2cm}%
]
    \node[mod] (a) {%
        Alpha
        \nodepart[font=\normalfont]{two} betas
        \nodepart[font=\normalfont]{three} foo
        \nodepart[font=\normalfont]{four} bar
    };
    \node[mod,right=of a.two east,anchor=one west] (b) {%
        Beta
        \nodepart[font=\normalfont]{two} gammas
        \nodepart[font=\normalfont]{three} foo
        \nodepart[font=\normalfont]{four} bar
    };
    \node[mod,right=of b.two east,anchor=one west] (c) {%
        Gamma
        \nodepart[font=\normalfont]{two}  deltas
        \nodepart[font=\normalfont]{three} foo
        \nodepart[font=\normalfont]{four} bar
    };
    \draw[->] (a.two east) -- (b.text west);
    \draw[->] (b.two east) -- (c.text west);
\end{tikzpicture}

\end{document}

enter image description here

2
  • 1
    That’s fantastic, thank you! May I ask what anchor=text west means? I can see that without it, the nodes aren’t properly aligned. Does text mean the first node part here?
    – bp99
    May 29, 2020 at 13:42
  • 2
    @bp99 Yes, precisely. See p. 822 of pgfmanual v3.1.5 for the anchors. (One can use one west instead.)
    – user194703
    May 29, 2020 at 13:46

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.