# Tikz: How to split Nodes and position Text in it

I have a really big problem:

I need a TikZ node that looks like that:

but i have no idea how to split the node like that. Esecially the "more text" is a big problem. All i tried ended in errors. So I'm at the beginning again. Can anybody out there help me please?.

my last code did look like that but didn't work...

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{arrows}
\usetikzlibrary{calc,positioning}

\begin{document}
\begin{tikzpicture}
\node[name=data, rectangle split, rectangle split horizontal, rectangle split draw    splits=false, draw, rounded corners=5pt] {1 \nodepart{two} 2 \nodepart{three} 3    \nodepart{four} 4 \nodepart{five} 5 \nodepart{six} 6};
\foreach \subnode in {1,...,5}% counter goes 1 to number_of_subnodes-1
{\draw[dashed] ($(data.north east)!{\subnode*0.25}!(data.north west)$) -- ($(data.south east)!{\subnode*0.25}!(data.south west)$);}
\end{tikzpicture}
\end{document}


One more Question: Why is CMD not centered???

\node[name=data, rectangle split, very thick,
rectangle split horizontal,
rectangle split parts=6,
rectangle split draw splits=true,
draw, rounded corners=2pt,
label={[fill=white,inner sep=0pt,font=\tiny]center:Daten/Parameter},
align=center,
text width=2.5em,
inner sep=2pt,
font=\tiny] at (mega88)
{CMD\nodepart{two} ~
\nodepart{three} ~
\nodepart{four} ~
\nodepart{five} ~
\nodepart{six}CS};

-
 Welcome to TeX.sx! No need to add thanks, simply upvote any good answers you may receive. – Peter Jansson Feb 23 at 19:54

By default rectangle split has 4 parts, so if you need more, you have to explicitly fix them with rectangle split parts=number_you_want.

Second problem is more text. I used another node on top of splited one. \node[fill=white,inner sep=1pt] draws a white background node, a little bit smaller than the previous one. The result is:

and the complete code to do it is:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{arrows}
\usetikzlibrary{calc,positioning}

\begin{document}
\begin{tikzpicture}
\node[name=data, rectangle split,
rectangle split horizontal,
rectangle split parts=6,
rectangle split draw splits=true,
draw, rounded corners=5pt] (main)
{text \nodepart{two} 2
\nodepart{three} 3
\nodepart{four} 4
\nodepart{five} 5
\nodepart{six} text};

\node[fill=white,inner sep=1pt] at (main.center) {more text};

\end{tikzpicture}
\end{document}


You don't need to write anything inside parts 2 to 5, but I left there to show you how more text node covers them.

EDIT: more text as a label.

Another option would be to use label option instead of a second node. In fact label are like nodes, so you can fix their options. In this case you have to fix its width (via minimum size or text width) to be sure of covering the empty parts. If you want to use different size for filled and empty parts, use option text width for filled ones and rectangle split empty part width for empty ones. Empty parts are not declared, textpart{two} ~ is not an empty part, it's a part with ~ (non breakable space) inside. If text width is wider than the text inside, it will be aligned to the left, so add align=center to place it centered in its space.

Now the code with all this suggestions

\begin{tikzpicture}
\node[name=data, rectangle split,
rectangle split horizontal,
rectangle split parts=6,
rectangle split draw splits=true,
draw, rounded corners=5pt,
text width=2cm,
align=center,
rectangle split empty part width=5mm,
label={[fill=white,
inner sep=1pt,
text width=2.5cm,
align=center]center:more text \dots},
] (main)
{CMD
%   \nodepart{two} ~
%   \nodepart{three} ~
%   \nodepart{four} ~
%   \nodepart{five} ~
\nodepart{six} CS};
\end{tikzpicture}


and the result

-
 Thank you! Thanks a lot! new problem: How to add a fixed width to the parts?! – donLuigi Feb 23 at 20:07 @donLuigi: Your wellcome! Please look at second option, I think it's easier to use it than first one. – Ignasi Feb 23 at 20:18 I'm |-| that faar away from usin Paint... "rectangle split empty part width=xyz" why is there no "rectangle split part width=xyz" – donLuigi Feb 23 at 20:25 @donLuigi: you can use text width to fix width of not empty parts. – Ignasi Feb 23 at 20:33 Thank you so much! – donLuigi Feb 23 at 20:50
show 1 more comment