Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}  
share|improve this question
    
If you are not planning to put varying sized things inside then you can just draw it. \draw[help lines,thin,black] (0,0) grid[step=1cm] (2cm,3cm); –  percusse Feb 17 '13 at 0:53
    
Sorry, I should have been more explicit. I need to put text in each cell. I am editing the original question to make this clear. –  ozsu Feb 17 '13 at 1:05
    
Why don't you use tabular? –  Harish Kumar Feb 17 '13 at 1:16
    
Inside tikz? Didn't know you could do that. –  ozsu Feb 17 '13 at 1:21
    
@ozsu In a node, you most certainly can. But for the example you ask for, you won’t even need TikZ. Can you provide a MWE? –  Qrrbrbirlbel Feb 17 '13 at 1:27
show 2 more comments

1 Answer 1

up vote 10 down vote accepted

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.

share|improve this answer
    
THank you much; I'll use this. –  ozsu Feb 17 '13 at 2:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.