7

I am trying to draw a 3x2 rectangle. I am not sure if multipart rectangle can do it, but it seems that multipart can only do one-dimensional arrays. I tried matrix, but then I cannot get the lines in between cells or around the rectangle. I need to put text in each cell. What I want to get is a rectangle with the following with the box around and horizontal and vertical lines in between cells:

Aid   Value
 1     R1
 2     R2

This needs to be inside a tikz environment. Here is what I have as a minimal code and it is fine except for the matrix part on the right:

\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}  
Moriambar
  • 11,466
ozsu
  • 2,385

1 Answers1

10

One option is to use a tabular as the contents for a node:

\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}

enter image description here

I changed from the old syntax with \tikzstyle to \tikzset.

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128