# TikZ matrix vs. shapes.multipart vs. text width

I'm wondering if anyone can make sense of the error I get when I try to set the text width in a matrix of multipart nodes.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes.multipart}
\begin{document}
\begin{tikzpicture}[every text node part/.style={font=\large\sffamily},
every two node part/.style={font=\normalsize\sffamily,%text width=0.5cm %<- causes an error
}]
\matrix[matrix of nodes,nodes={draw,rectangle split,rectangle split parts=2,
rectangle split draw splits=false}%,text width=0.5cm %<- causes an error
] {
top\nodepart{two}some lengthy text at the bottom & x\nodepart{two} y\\
x\nodepart{two} y & top\nodepart{two}bottom \\
};
\end{tikzpicture}
\end{document}


Each attempt to set the text width causes an error.

It has been stated by Ulrike Fischer that

All options starting with text such as text width have no effect.

in a matrix. I'd be happy to believe that if it was not for the following counterexample:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,nodes={draw},text width=0.5cm
] {
top some lengthy text at the bottom & x  y\\
x  y & top bottom \\
};
\end{tikzpicture}
\end{document}


In my humble opinion this shows that it is possible to set the text width in a matrix of non-multipart nodes.

NEW INSIGHTS(?): One actually can set the size of multipart nodes, at least to some extent.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes.multipart}
\begin{document}
\begin{tikzpicture}[every text node part/.style={font=\large\sffamily},
every two node part/.style={font=\normalsize\sffamily,%text width=0.5cm %<- causes an error
}]
\matrix[matrix of nodes,nodes={draw,rectangle split,rectangle split parts=2,
rectangle split draw splits=false}%,text width=0.5cm %<- causes an error
] {
top\nodepart[text width=1.5cm]{two}some lengthy text at the bottom &
x\nodepart{two} y\\
x\nodepart{two} y & top\nodepart{two}bottom \\
};
\end{tikzpicture}
\end{document}


However, repeating this trick at any of the right (right-most?) nodes fails. Yet one can add empty nodes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes.multipart}
\begin{document}
\begin{tikzpicture}[every text node part/.style={font=\large\sffamily},
every two node part/.style={font=\normalsize\sffamily,text width=1cm %<- causes an error
}]
\matrix[matrix of nodes,nodes={draw,rectangle split,rectangle split parts=2,
rectangle split draw splits=false}%,text width=0.5cm %<- causes an error
] {
top\nodepart{two}some lengthy text at the bottom &
x\nodepart{two} y &\\
x\nodepart{two} y & top\nodepart{two}bottom &\\
};
\end{tikzpicture}
\end{document}


ACKNOWLEDGMENTS: I acknowledge useful comments by Torbjørn T., Ulrike Fischer, Dr. Manuel Kuehner and @cfr.

QUESTION: Is there a way to set the text width of the multipart nodes in a matrix of nodes?

• "All options starting with text such as text width have no effect." in a matrix. – Ulrike Fischer May 1 '18 at 17:41
• @UlrikeFischer Then please compile the second example. It does work there. (And sorry for the misleading comment in the TeX file.) – marmot May 1 '18 at 17:42
• It's not ignored, you're using the wrong style name. You have \nodepart{two}, so it should be every two node part/.style={..}. – Torbjørn T. May 1 '18 at 18:03
• @TorbjørnT. Yes, you are right. My mistake. However, if I do as you suggest I am back to the error. – marmot May 1 '18 at 18:07
• I took the liberty adding screenshots of each MWE, hope that's ok. – Dr. Manuel Kuehner May 1 '18 at 18:59