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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry but this is the MWE I could post. I also attached the image. The top image is what I am getting and the bottom one is what I desire. I manage to create nodes but do not know how to connect them. I tried this \draw[-latex] (16.south) |- (28.south); but that did not give me good output. Also I put a mini page with two tables. The gap between them is less however I desire bigger gap as shown in the desired output

Thanks for your help


    \tikz[overlay,remember picture] 
        \node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
    \tikz[overlay,remember picture]
        \node (marker-\arabic{nodemarkers}-b) at (0,0){};%
    \tikz[overlay,remember picture,inner sep=2pt]
        \node[draw,ellipse,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%

\newcommand\fb\FloatBarrier % to put float barriers

% Introduce a new counter for counting the nodes needed for circling
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}
% Some options common to all the nodes and paths
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
minimum width=1cm,align=center,text depth=0.5ex,outer sep=1pt]
\tikzstyle{every path}+=[thick, rounded corners]

\begin{tabular}{l l c l}
& \tabnode{}& \tabnode{}&  \tabnode{} \\
 & \tabnode{A} & \tabnode{D} &  \tabnode{G} \\  
I & \tabnode{B} & \tabnode{E} & \tabnode{H}  \\  
 & \tabnode{C} & \tabnode{F} & \tabnode{I}  \\  
& & & \\
& & & \\
& & & \\
& & & \\
II & \tabnode{One} & \tabnode{Two }& \tabnode{Three}   \\
& & & \\
& & & \\
III & \tabnode{First}& \tabnode{Second }& \tabnode{Third}  \\
\begin{tabular}{l l c l}
& \tabnode{}& \tabnode{}&  \tabnode{} \\
I & \tabnode{X} & \tabnode{Y} & \tabnode{Z}  \\  
& & & \\
& & & \\
II & \tabnode{x} & \tabnode{y }& \tabnode{z}   \\
& & & \\
& & & \\
III & \tabnode{Xx }& \tabnode{Yy }& \tabnode{Zz}  \\

\draw [Green] (4.west) -- (1.north west) -- (1.north east) -- (10.south east) -- (10.south west) -- cycle;
\draw [red] (5.west) -- (2.north west) -- (2.north east) -- (11.south east) -- (11.south west) -- cycle;
\draw [blue] (6.west) -- (3.north west) -- (3.north east) -- (12.south east) -- (12.south west) -- cycle;

\draw [Green] (16.west) -- (16.north west) -- (16.north east) -- (16.south east) -- (16.south west) -- cycle;
\draw [red] (17.west) -- (17.north west) -- (17.north east) -- (17.south east) -- (17.south west) -- cycle;
\draw [blue] (18.west) -- (18.north west) -- (18.north east) -- (18.south east) -- (18.south west) -- cycle;

\draw [Green] (28.west) -- (28.north west) -- (28.north east) -- (28.south east) -- (28.south west) -- cycle;
\draw [red] (29.west) -- (29.north west) -- (29.north east) -- (29.south east) -- (29.south west) -- cycle;
\draw [blue] (30.west) -- (30.north west) -- (30.north east) -- (30.south east) -- (30.south west) -- cycle;

\draw[-latex] (16.south) |- (28.south);

enter image description here

share|improve this question
Thanks for posting a complete document. However, the current MWE that you posted is not compilable. Please correct. – Peter Grill Mar 19 '12 at 16:54
I added a working example now. – Aku Mar 19 '12 at 18:12
\path[-latex] (16.south) edge [bend right,Green] (28.south); this worked great for connecting the node, I am not sure if this is the best way to do but it worked. – Aku Mar 19 '12 at 18:35
up vote 4 down vote accepted

I think you can simplify a little further for that kind of tables which has different node shapes and colors. You can enter the table contents into a matrix and manipulate the styles of rows and columns. Moreover, you can inject individual styles to the cells via the use of |[node style options]|. The advantage of the is that everything takes place in one tikzpicture and you don't need to tame anything. Here is an example:

\tikzset{rn1/.style={   text width=1.5 ex, minimum width=8ex,rounded corners },
            rn2/.style={minimum width=10mm, rounded corners},
                nodes in empty cells,
                matrix of nodes,
                row sep=2mm,
            column sep=3mm
            row 1/.style={rn1,anchor=center},
            row 3/.style={rn2}
            ] (L) {
I  &|[draw=green]| A B C &|[draw=red]| E F G & |[draw=blue]| H J I\\
II & One & Two & Three\\
III &|[draw=green]| First &|[draw=red]|  Second & |[draw=blue]| Third\\
\matrix[mymatrix,row 3/.style={rn2}] (R) at (8cm,0) {% We shift it to the right
I  &X &Y & Z\\
II & x & y & z\\
III &|[draw=green]| Xx &|[draw=red]|  Yy & |[draw=blue]| Zz\\
\draw[bend right,green] (L-3-2) to (R-3-2);
\draw[bend right,red] (L-3-3) to (R-3-3);
\draw[bend right,blue] (L-3-4) to (R-3-4);

The text width option is actually for a line break after approx. one character such that A B C is typed in 3 lines.

enter image description here

share|improve this answer

I get errors running your MWE, perhaps my instalation is a bit old, but on the face of it

 \begin{tabular}{l l c l}

is what you are asking for, and will separate the tables.

share|improve this answer
\hspace worked great however I still do not know how to connect the nodes with freestyle line as shown in the attached image – Aku Mar 19 '12 at 18:13

Your Answer


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.