绘制 3x2 矩形

绘制 3x2 矩形

我正在尝试绘制一个 3x2 矩形。我不确定多部分矩形是否可以做到这一点,但多部分似乎只能做一维数组。我尝试了矩阵,但我无法在单元格之间或矩形周围得到线条。我需要在每个单元格中放入文本。我想要得到的是一个矩形,周围有框,单元格之间有水平和垂直线:

Aid   Value
 1     R1
 2     R2

这需要在 tikz 环境中进行。这是我的最小代码,除了右侧的矩阵部分外,其他都很好:

\documentclass{scrartcl}        

\usepackage{tikz}
\usetikzlibrary{shapes,fit,positioning,arrows,matrix}


\begin{document}
\begin{tikzpicture}
\tikzstyle{bigbigbox} = [minimum width=3.5cm, draw, thick, rounded corners, rectangle]
\tikzstyle{bigbox} = [draw, thick, rounded corners, rectangle]
\tikzstyle{box} = [minimum width=2.7cm, rounded corners,rectangle, fill=blue!20]

 \node[align=center,draw,shape=rectangle split,
       rectangle split parts=3, text width=1.0cm,text centered] (A)
        {Value \nodepart{two}R1\nodepart{three}R2};

\node[rectangle, draw,right of=A,xshift=1cm,rotate=90] (A1) {map};
  \matrix (A2) [matrix of nodes,row sep=0em,column sep=0em, right of=A1,xshift=1cm]
  {
     Aid & Value \\
     1 & R1 \\
     2 & R2 \\};

 \node[align=center,shape=rectangle split,
       rectangle split parts=2, text width=2cm,text centered,above of=A,yshift=0.3cm] (A3)
        {Mapper 1 \nodepart{two}R};

\draw[-triangle 90, line width=1mm, blue!50,postaction={draw=blue!50, line width=3mm, shorten >=0.2cm, -}] (A.east) -- (A1.north);

\node[bigbox] [fit = (A3) (A2)] (box1){};

\end{tikzpicture}

\end{document}  

答案1

一种选择是使用tabular作为节点的内容:

\documentclass{scrartcl}        
\usepackage{tikz}
\usetikzlibrary{shapes,fit,positioning,arrows,matrix}

\begin{document}

\begin{tikzpicture}
\tikzset{
bigbigbox/.style = {minimum width=3.5cm, draw, thick, rounded corners, rectangle},
bigbox/.style = {draw, thick, rounded corners, rectangle},
box/.style = {minimum width=2.7cm, rounded corners,rectangle, fill=blue!20}
}

 \node[align=center,draw,shape=rectangle split,
       rectangle split parts=3, text width=1.0cm,text centered] (A)
        {Value \nodepart{two}R1\nodepart{three}R2};

\node[rectangle, draw,right of=A,xshift=1cm,rotate=90] (A1) {map};

\node[right of=A1,xshift=1cm] (A2)
{
\renewcommand\arraystretch{1.15}
\begin{tabular}{|c|c|}
\hline
Aid & Value \\
\hline
1 & R1 \\
\hline
2 & R2 \\
\hline
\end{tabular}
};

 \node[align=center,shape=rectangle split,
       rectangle split parts=2, text width=2cm,text centered,above of=A,yshift=0.3cm] (A3)
        {Mapper 1 \nodepart{two}R};

\draw[-triangle 90, line width=1mm, blue!50,postaction={draw=blue!50, line width=3mm, shorten >=0.2cm, -}] (A.east) -- (A1.north);

\node[bigbox] [fit = (A3) (A2)] (box1){};
\end{tikzpicture}

\end{document}

在此处输入图片描述

\tikzstyle我将旧语法改为\tikzset

相关内容