I am trying to stack 2 Tikz nodes directly below each other with no space and without having the double-thick shape between them. Furthermore, both nodes should have the same width, either fixed or determined by the with of the bottom node. My First try is:
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\makeatletter
\pgfdeclareshape{recttop}{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\backgroundpath{% this is new
% store lower right in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% construct main path
\pgfsetcornersarced{\pgfpoint{5pt}{5pt}}
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfsetcornersarced{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
}
}
\pgfdeclareshape{rectbottom}{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\backgroundpath{% this is new
% store lower right in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% construct main path
\pgfsetcornersarced{\pgfpoint{0pt}{0pt}}
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfsetcornersarced{\pgfpoint{5pt}{5pt}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
%[every node/.style={fill=gray,minimum width=2cm, minimum height=1cm}]
\matrix[row sep=0pt, every node/.style={draw}]{
\node[draw, shape=recttop, fill=red!20] (top) {CFunction};\\
\node[draw, shape=rectbottom] (bottom) {\ttfamily func(A, E, B, Z);};\\
};
\end{tikzpicture}
\end{document}
Which results in
which does not look like I want it. I need the upper node as wide as the lower one and without the double drawn line in the middle of them. Alternatively a construct which realized a similar look.