有两个用 TiKZ 的多部分节点绘制的框。
如何绘制高度更大的下部框?(下部框应留有更多垂直空间)
\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
不幸的是,multipart
节点无法定义不同的高度,因此您需要向部分内容添加一些支撑。例如:
\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}