在 tikz 中用单元格绘制框

在 tikz 中用单元格绘制框

我想画一个像附图这样的图表。可以给我一些建议吗在此处输入图片描述

在此处输入图片描述

答案1

欢迎来到 TeX.SE!有几种实现此目的的方法,以下是基于matrix库的方法之一。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}[mymat/.style={matrix of nodes,
nodes={fill=red,draw,text=white,font=\sffamily\bfseries,text width=1.5cm,
text height=11pt,text depth=3pt,baseline=center},
column sep=-\pgflinewidth/2}]
\matrix[mymat] (matTL) {
Text1 & Text2 & Text3\\
};
\matrix[mymat,right=2cm of matTL] (matTR) {
V1 & V2 & V3\\
};
\matrix[mymat,below=2cm of matTL.west,anchor=west] (matBL) {
Text4 & new & Text5 & Text6\\
};
\draw[-latex] (matTL-1-3) -- (matTR-1-1);
\foreach \X in {1,2,3}
{\draw[-latex] (matBL-1-1) -- (matTL-1-\X);}
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者您也可以使用shapes.multipart

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.multipart,positioning}
\begin{document}
\begin{tikzpicture}[my shape/.style={rectangle split, rectangle split parts=#1,
fill=red,draw,text=white,font=\sffamily\bfseries,text width=1.5cm,text
height=11pt,text depth=3pt,rectangle split horizontal,
rectangle split part align=base}]
\node [my shape=3] (TL)
{Text1\nodepart{two}Text2\nodepart{three}Text3};
\node [my shape=3,right=2cm of TL] (TR)
{V1\nodepart{two}V2\nodepart{three}V3};
\node [my shape=4,below=2cm of TL.west,anchor=west] (BL)
{Text4\nodepart{two}new\nodepart{three}Text5\nodepart{four}Text6};
\draw[-latex] (TL) -- (TR);
\foreach \X in {one,two,three}
{\draw[-latex] (BL.one north) -- (TL.\X\space south);}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容