2

There are two boxes draw with multi-part nodes of TiKZ.

How to draw the lower box with more height? (the lower box should be with more vertical space)

\documentclass[border=10pt]{standalone}
\usepackage{tikz, tkz-graph}
\usetikzlibrary{arrows,arrows.meta,shapes,positioning,automata}
\usetikzlibrary{matrix,chains}
\thispagestyle{empty}
\usepackage{xcolor}
\definecolor{colorBall}{RGB}{51, 153, 204}
\definecolor{colorCircle}{RGB}{0, 255, 0}

\tikzset{
    multirectangle/.style={
        minimum width=20mm,
        minimum height=18mm,
        inner ysep=3mm,
        anchor=center,
        draw,
        fill=orange!20!white
    }
}
\begin{document}
\begin{tikzpicture}
\node (A) [rectangle split, rectangle split parts=2, multirectangle]{
    \textbf{float}
    \nodepart{two}
    $123.5$
};
\end{tikzpicture}
\end{document}

1 Answer 1

0

Unfortunately to multipart nodes is not possible to define different heights, so you need add some strut to part's content. For example:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz, tkz-graph}

\usetikzlibrary{arrows.meta,automata,
                chains, matrix,
                positioning,
                shapes.multipart}   % <---
\newlength{\nph}                    % node part height

\begin{document}
\begin{tikzpicture}[
mpnv/.style = {draw,
    rectangle split,
    rectangle split parts=2,
               }
                    ]
\setlength{\nph}{22mm}                          % define node part height
\pgfmathsetlengthmacro{\npd}{0.48\nph}          % calculating node part baseline
\newcommand\mystrut{\rule[-\npd]{0pt}{\nph}}    % define new strut

\node (a) [mpnv] {
    \nodepart{one} \textbf{float}
    \nodepart{two} $123.5$ \mystrut %  <----------
                };
\end{tikzpicture}
\end{document}

enter image description here

1
  • Fantastic! Thanks!
    – xaero
    Jan 5 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.