问题是如何绘制E
具有正确尺寸的节点以覆盖下面的四个节点。
我现在有的是:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
block/.style={
rectangle,
rounded corners,
inner sep=1em
}
]
\path node[block,white,fill=jeans] (mathsat) {MathSAT\strut};
\path (mathsat.east) ++(2pt,0) node[block,anchor=west,white,fill=jeans]
(z3) {Z3\strut};
\path (z3.east) ++(2pt,0) node[block,anchor=west,white,fill=jeans]
(minisat) {MiniSAT\strut};
\path (minisat.east) ++(2pt,0) node[block,anchor=west,white,fill=jeans]
(cmsat) {CryptoMiniSAT\strut};
\end{tikzpicture}
\end{document}
它只绘制了下面的四个块。
如何在四个精确宽度的块上方绘制一个节点?
答案1
fit
和库确实很有帮助。请注意,如果希望拟合正确进行,则matrix
必须在前两行上使用。如果您选择让所有列的大小相同,则这不再是强制性的。\hphantom
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,fit}
\begin{document}
\begin{tikzpicture}
\tikzset{block/.style={
rounded corners, fill=cyan,text=white,inner sep=0pt,outer sep=0pt}}
\matrix (m) [matrix of nodes,
nodes in empty cells,
nodes={rounded corners,
minimum height=1cm,
inner sep=1em,
outer sep=0pt},
column sep=1mm,
row sep=1mm,
row 1/.style = {nodes={minimum height=2cm}},
row 2/.style = {nodes={minimum height=3cm}},
row 3/.style = {nodes={fill=cyan, text=white}},
]
{
\hphantom{MathSAT} & \hphantom{Z3} & \hphantom{MiniSAT} & \hphantom{CryptoMiniSAT}\\
\hphantom{MathSAT} & \hphantom{Z3} & \hphantom{MiniSAT} & \hphantom{CryptoMiniSAT}\\ MathSAT & Z3 & MiniSAT & CryptoMiniSAT \\
};
\node[block,fit=(m-1-1)(m-1-4)]{YOUR F NODE};
\node[block,fit=(m-2-1)(m-2-4)]{YOUR E NODE};
\end{tikzpicture}
\end{document}