# Combine rectangle split with array

I want to draw a "complicated" figure, like shown below.

What is need to be done:

1. Enlarge the \hdashline to fit the hole width (drawn in red)
2. Remove the dashed line (:) from the first row (done per hand)

MWE:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}

\begin{tikzpicture}
\node[rectangle split,rectangle split parts=2, draw, inner sep=+0pt] {
$\begin{array}{l|l|l} n & loooooooooooooong & m\\ \end{array}$
\nodepart{two}
$\begin{array}{l@{{}={}}l:l@{{}={}}l} a & 0 & b & 0\\ \hdashline c & 0 & d & 0\\ \end{array}$};
\end{tikzpicture}

\end{document}


Update:

This should also work, if the second array contains more than two rows (e. g. 3 or 4)

What is need to be done:

1. Remove the dashed line (:) from the first row (green rectangle in upper figure)
2. Somehow the \draw[dashed,green] and \hline don't have exactly the same y-coordinate
3. Somehow the helpers add whitespace
4. Replace the hardcoded line width

Code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,calc}

\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}

\begin{tikzpicture}
\node (n) [rectangle split,rectangle split parts=2, draw, inner sep=+0pt] {
$\begin{array}{l|l|l} n & loooooooooooooong & m\\ \end{array}$
\nodepart{two}
$\begin{array}{l@{{}={}}l:l@{{}={}}l} a & 0 & b & 0\\ \hline %only for position control c & 0 & d & 0\\ c & 0 & d & 0\\ c & 0 & d & 0\\ \end{array}$};

%helper
\node[inner sep=0] (two north west) at ($(n.text split west)-(0,0.2pt)$) {}; %hardcoded
\node[inner sep=0] (two south west) at ($(n.south west)+(0,0.4pt)$) {}; %hardcoded
\node[inner sep=0] (two north east) at ($(n.text split east)-(0,0.2pt)$) {}; %hardcoded
\node[inner sep=0] (two south east) at ($(n.south east)+(0,0.4pt)$) {}; %hardcoded

\draw[dashed,green] ($(two south west)!0.75!(two north west)$) -- ($(two south east)!0.75!(two north east)$);

\end{tikzpicture}

\end{document}


I use the helpers, because a!0.75!b+c seems to be interpreted as (a!0.75!b)+c and I'm not able to do something like a!0.75!(b+c)

• a!0.75!(b+c) should be doable as ($(a)!0.75!($(b)+(c)$)$). The hardcoded shifts seem to coincide with \pgflinewidth and \pgflinewidth/2, respectively. – user121799 Feb 28 at 16:39

like this:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}
\begin{tikzpicture}
\node (n) [rectangle split,rectangle split parts=2, draw,
inner ysep=0pt] {
$\begin{array}{ c|c|c } n & loooooooooooooong & m\\ \end{array}$
\nodepart{two}
$\begin{array}{ r:l } a = 0 & b = 0\\ c = 0 & d = 0\\ \end{array}$
};
\draw[dashed] (n.two west) -- (n.two east); % <-- horizontal dashed line
\end{tikzpicture}
\end{document}


addendum: i'm still not sure how your table should looks. now, after edited your question, i guessing, that your table in second part of node can has any number of lines and you like to have aligned equations in rows at sign =. for example like this:

in this case my first suggestion doesn't gives desired result. in it you need to make the following changes:

• use tabularx environment instead array
• for aligning of equations at sign˙=thetabularx need four columns
• define width of node

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usepackage{tabularx}
\usepackage{arydshln}
\newlength\tabwidth     % for defining node width

\begin{document}
\begin{tikzpicture}
\settowidth\tabwidth{$\begin{array}{l|l|l} % calculating node width n & loooooooooooooong & m\\ \end{array}$}
\node (n) [rectangle split,rectangle split parts=2, draw, inner sep=0pt] {
$\begin{array}{l|l|l} n & loooooooooooooong & m\\ \end{array}$
\nodepart{two}
\begin{tabularx}{\tabwidth}{@{}                 % table width is equal to node width
>{\raggedleft\arraybackslash $}X<{$}@{$\,=\,$}
>{\raggedright\arraybackslash$}X<{$}:
>{\raggedleft\arraybackslash $}X<{$}@{$\,=\,$}
>{\raggedright\arraybackslash$}X<{$}
@{}}
a & 0 & b & 1234\\
\hdashline
abc & 0 & d & 0\\
\hdashline
abcd & 0 & d & 0\\
\hdashline
c & 0 & d & 0\\
\end{tabularx}
};
\end{tikzpicture}
\end{document}

• can you please explain (n.two west) -- (n.two east). Isn't it supposed to be to instead of two. – subham soni Feb 28 at 12:46
• @subhamsoni see page 796 of the documentation. two refers to the second part – Ben Feb 28 at 13:43
• @zarko well, this doesn't work, if the (second) array has more than two rows, does it? Or is it possible to correct this with a yshift? Btw, you missed the part of removing the dashed line between a and b – Ben Feb 28 at 13:47
• (The l@{{}={}}l:l@{{}={}}l is there with purpose, to align the equations above and below the dashed line. if this is possible by something else, there might be a hole other solution (but the alignment is irrelevant for your solution.)) Is there a difference between 0pt and +0pt? I found +0pt in this answer – Ben Feb 28 at 14:05
• @Ben, my solution is tested (twice) and it works!i haven't any idea how you use it. zero is zero. i do not know for positive or negative zero, why Qrrbrbirlbel use this notation, i don't know. you should ask him. however, even use his notation my example, it works. – Zarko Feb 28 at 14:37

This is more a comment but it is too long for a comment. One can draw the lines without hardcoded distances.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,calc}

\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}

\begin{tikzpicture}
\node (n) [rectangle split,rectangle split parts=2, draw, inner sep=+0pt] {
$\begin{array}{l|l|l} n & loooooooooooooong & m\\ \end{array}$
\nodepart{two}
$\begin{array}{l@{{}={}}l:l@{{}={}}l} a & 0 & b & 0\\ \hline %only for position control c & 0 & d & 0\\ c & 0 & d & 0\\ c & 0 & d & 0\\ \end{array}$};
\pgfmathtruncatemacro{\NumRows}{4}
\foreach \X in {1,...,\numexpr\NumRows-1} % \numexpr trick from https://tex.stackexchange.com/a/477077/121799
{\coordinate (aux-\X) at ($(n.text split)!\X/\NumRows!(n.south)$);
\draw [blue,dashed] (aux-\X-|n.west) -- (aux-\X-|n.east);
}
\end{tikzpicture}
\end{document}
`