TikZ: create single part node from multipart one with default text

I would like to create a style I can give to a node such that it is a multipart node (2-part, say) with one part's text fixed.

I know I how to create multipart nodes using, e.g., circle split and how to then select the lower part with \nodepart{lower}. I also know that I can set default text using node contents, but this seems only to apply to simple nodes.

How can I set a default text to arbitrary node parts of multipart nodes?

• @Zarko: I am aware of this; circle split was an example. Apr 21 '16 at 19:03

Probably it's not what you want but if there is no better solution ...

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\begin{document}
\begin{tikzpicture}[mynode/.style={rectangle split, rectangle split parts=2, draw, node contents=#1},
mynode/.default={A\nodepart{two}B}]
\node (A) [mynode];
\node[right=5mm of A] (B) [mynode={C}];
\node[right=5mm of B] (C) [mynode={\nodepart{two}D}];
\end{tikzpicture}
\end{document}


If you want always the same part with fixed contents, define it inside .style and left the other one as parameter:

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\begin{document}
\begin{tikzpicture}[mynode/.style={rectangle split, rectangle split parts=2, draw, node contents={#1\nodepart{two}Constant}},
]
\node (A) [mynode=A];
\node[right=5mm of A] (B) [mynode=B];
\node[right=5mm of B] (C) [mynode=C];
\end{tikzpicture}
\end{document}


• Acually, your second solution is exactly what I want. (I tried something similar, but it didn't work, probably because I'm using it in a \graph; your code also doesn't work there... but that's material for another question.) Apr 21 '16 at 20:41