Some ideas, lots of hardcoded magic numbers (found by trial and error):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds, calc, shadows, shadows.blur}
\newcommand\addcurlyshadow[2][]{
% #1: Optional aditional tikz options
% #2: Name of the node to "decorate"
\begin{pgfonlayer}{background}
\path[
rounded corners=1pt,
blur shadow={shadow xshift=0pt,
shadow yshift=-0.3pt,
shadow blur steps=6,
shadow blur radius=.6pt}, #1]
($(#2.north west)+( 0.3pt,0)$) --
($(#2.south west)+( 0.3pt,0)$) --
($(#2.south east)+(-0.3pt,0)$) --
($(#2.north east)+(-0.3pt,0)$) --
cycle;
\path[rounded corners,
blur shadow={shadow xshift=0pt,
shadow yshift=0pt,
shadow blur steps=8,
shadow blur radius=2pt}, #1]
($(#2.north west)+(-1pt,-2pt)$) --
($(#2.south west)+(-1pt, 2pt)$) --
($(#2.south east)+( 1pt, 2pt)$) --
($(#2.north east)+( 1pt,-2pt)$) --
cycle;
\end{pgfonlayer}
}
\begin{document}
\begin{tikzpicture}
\begin{pgfonlayer}{background}
\fill[black!20] (-3,-1) rectangle (3,1);
\end{pgfonlayer}
\node[fill=white, rectangle, minimum width=3cm, minimum height=1cm]
(example) {Test};
\addcurlyshadow{example}
\end{tikzpicture}
\end{document}
Result:
Try with the shapes.multipart
library of tikz
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\begin{document}
\tikzset{
split/.style={rectangle split, rectangle split parts=2,draw,
minimum width=1.5cm,rounded corners,minimum height=1cm,
text width=2cm,align=center,inner ysep=2cm}
}
\begin{tikzpicture}
\node[split] at (8,0) { A \nodepart{two} BBBBBBB\\ BBBB};
\end{tikzpicture}
\end{document}
Another possibility is to use a matrix
, in which case you can add any directives to the cells.
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix,calc}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,nodes={text height=0.5cm,text width=0.5cm,align=center},draw,rounded corners] (mat)
{ A \\
{B \\ C} \\
};
\path ($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux);
\draw (aux -|mat.west) -- (aux -|mat.east);
\end{tikzpicture}
\end{document}
Or you can just use fit
to draw a contour around two stacked nodes, to which you can pass any parameters you like.
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning,fit}
\begin{document}
\begin{tikzpicture}
\node (A) {A};
\node[below=1mm of A,align=center,text height=8mm] (B) {B\\ C};
\node[fit=(A) (B),draw,rounded corners] (mat){};
\path (A.south) -- (B.north) coordinate[midway] (aux);
\draw (aux -|mat.west) -- (aux -|mat.east);
\end{tikzpicture}
\end{document}
Best Answer
You can pass the
text width
option directly to the\nodepart
or you can set thestyle:
Note you need to explicitly label the first part of the node for this to take effect.
See Should \tikzset or \tikzstyle be used to define TikZ styles? for discussion of
\tikzset
vs.\tikzstyle