How to change the height of just one nodepart in TikZ?

I want to change the height of one part of the node to the minimum possible. How can I do this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[rectangle split,rectangle split parts=3] {
first
\nodepart{second}
\nodepart{third}
third
};
\end{tikzpicture}
\end{document}


I want the second part (which is empty) to be 0.1cm in height.

-

1 Answer

You can use the key rectangle split empty part height to set the height of empty parts. However, this key only adds a a invisible rule with the given height to an internal macro. Therefore the height can't be reduced once set. The default value is 1ex. The overwrite this use the key rectangle split every empty part={} which deletes all previous set height, depth and width values.

The inner sep value is still added around the empty part which makes it very difficult to make it smaller without reducing this value.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[rectangle split,rectangle split parts=3,draw] {
XgX
\nodepart{second}
\nodepart{third}
XgX
};
\end{tikzpicture}
\begin{tikzpicture}
\node[rectangle split,rectangle split parts=3,inner sep=0pt,
rectangle split every empty part={},% delete existing height, depth and width
rectangle split empty part height=0.1cm,
draw] {
XgX
\nodepart{second}%
\nodepart{third}
XgX
};
\end{tikzpicture}
\end{document}

-
this is what LaTeX processor says: Package pgfkeys Error: I do not know the key '/tikz/rectangle split every empty part' and I am going to ignore it. Perhaps you misspelled it. Any ideas? –  yegor256 Feb 22 '11 at 19:02
@yegor256: Yes, update your TikZ/PGF package. Your seems to be outdated. –  Martin Scharrer Feb 22 '11 at 19:11