I am using multipart shapes to create two-sided nodes and want to change the background color of the left node based on a user-provided (color) parameter. Changing the default parameter at \tikzstyle{package}[green] also changes the background color in both outputs (Node 1+2), however I am not able to specify another color for some reason. Instead, the text color changes (Node 2).
The following example demonstrates this behavior:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes, shapes.geometric, shapes.multipart}
\tikzstyle{package}[green] = [
rectangle split,
rectangle split horizontal,
rectangle split parts=2,
rectangle split part fill = {
#1, gray
},
draw=black, very thick,
minimum height=2em,
inner sep=1cm,
every one node part/.style={
text=white,
text width=5cm
},
every two node part/.style={
text=white,
text width=\linewidth-7cm
}
]
\begin{document}
\begin{tikzpicture}
\node[package] {Node 1 \nodepart{two} Lorem Ipsum \\ dolor sit amet};
\end{tikzpicture}
\begin{tikzpicture}
\node[package][red] {Node 2 \nodepart{two} Lorem Ipsum \\ dolor sit amet};
\end{tikzpicture}
\end{document}
The following image shows the output. I want to fill the left side of the second node with red, instead of green.
I understand, that the red text color comes from the way, the node is drawn (i.e. the red does not actually specify my parameter, but instead the standard \node parameters). I also tried changing how to express this, for example \node[package][fill=red] or \node[package, red], but nothing worked as expected. So my question is: How do I add parameters to a tikzstyle and pass arguments when drawing a node? Also, is it possible to define multiple parameters?
Thanks in advance! :-)


\nodepart{one}is necessary in both examples for the text style parameters (textandtext width) to take effect. Odd. – sgmoye Jul 02 '19 at 18:24every upper node partin the style, but it didn't have any effect either. – Carsten Jul 03 '19 at 08:03every one node partat all. Leave it out and set thetextandtext widthproperties directly (e.g.style = { ..., text=white, text width=2cm, every two node part/.style = { ... }, ... }and everything works as expected. – Carsten Jul 04 '19 at 11:55