3

I'm trying to do something similar to what is shown in the picture, but do not even know where to start. I can get something similar with three tables and minipage environment. But I have no idea how to connect tables rows with arrows. Maybe I should use tikz for that, but I can't found similar examples with tables.

\documentclass{beamer}

\usepackage{tabu}
\usepackage{color}
\usepackage{xcolor, colortbl}

\begin{document}
\begin{table}[!htb]
    Interleaving example \\
    \begin{minipage}{.3\linewidth}
      \centering
        \begin{tabu}{|c|c|}
          \hline
          \rowcolor{green!25} 1 & $Document_a$ \\
          \hline
          \rowcolor{green!25} 2 & $Document_b$ \\
          \hline
          \rowcolor{green!25} 3 & $Document_c$ \\
          \hline
        \end{tabu}
        Ranking A
    \end{minipage}
    \begin{minipage}{.3\linewidth}
      \centering
        \begin{tabu}{|c|c|}
          \hline
            \rowcolor{green!25} 1 & $Document_a$ \\
          \hline
            \rowcolor{red!25} 2 & $Document_e$ \\
          \hline
           \rowcolor{green!25} 3 & $Document_b$ \\
          \hline
        \end{tabu}
        Shown to user
    \end{minipage}
    \begin{minipage}{.3\linewidth}
      \centering
        \begin{tabu}{|c|c|}
          \hline
          \rowcolor{red!25} 1 & $Document_e$ \\
          \hline
          \rowcolor{red!25} 2 & $Document_d$ \\
          \hline
          \rowcolor{red!25} 3 & $Document_f$ \\
          \hline
        \end{tabu}
        Ranking B
    \end{minipage} 
\end{table}

\end{document}

Desired results

6
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Commented May 31, 2015 at 10:20
  • Do you have special reason, that you use tables? Arrows is more simple to add if all is in ´´tikzpicture`` where instead tables you use ``multipart˙˙ nodes.
    – Zarko
    Commented May 31, 2015 at 10:21
  • @Zarko I haven't special reason for use tables, except I have no experience with tikz. Now I'll try to use multipart nodes.
    – interleave
    Commented May 31, 2015 at 10:31
  • Your MWE doesn't contain hypperref links as can be seen from your picture
    – Zarko
    Commented May 31, 2015 at 10:31
  • 1
    Does How to connect Beamer blocks by arrows? help? Commented May 31, 2015 at 10:35

2 Answers 2

4

I would use a tikz matrix of (math) nodes, together with some fancy arrows from the shapes.arrows library of tikz:

enter image description here

Here is the code:

\documentclass[border=5mm,tikz]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes.arrows}

\begin{document}
    \begin{tikzpicture}[>=stealth,->,shorten >=2pt,looseness=.5,auto,
        Red/.style={fill=red,text=white},
        fat arrow/.style={single arrow,shape border rotate=90,
                          thick,draw=blue!70,fill=blue!30,
                          minimum height=10mm},
        empty node/.style={minimum height=10mm,fill=none},
      ]
      \matrix (M)[matrix of math nodes,row sep=2mm,column sep=10mm,
                        nodes={text width=20mm,rectangle,fill=green!20}
      ]{
          \text{Document}_A & \text{Document}_a & \text{Document}_e\\
          |[Red]|\text{Document}_B & \text{Document}_b & |[Red]|\text{Document}_f\\
          \text{Document}_C & \text{Document}_c & |[Red]|\text{Document}_g\\
          |[empty node]|& |[empty node]|& |[empty node]|\\
          \text{Ranking A}& \text{Ranking A}& \text{Ranking A}\\
       };
       \draw[red,->](M-2-1.east)--(M-2-2.west);
       \draw[red,->](M-2-3.west)--(M-2-2.east|-M-2-3.west);
       \draw[red,->](M-3-3.west)--(M-2-2.south east);
       \node at (M-4-1) [fat arrow]{};
       \node at (M-4-2) [fat arrow]{};
       \node at (M-4-3) [fat arrow]{};
    \end{tikzpicture}
\end{document}

A few words of explanation:

  • The (M) in \matrix (M) means that the nodes in the matrix can be referred to as M-<row>-<col>
  • If you use matrix of math nodes then it is better to write \text{Document}_A etc, (the \text command is from the amsmath package), because otherwise it looks like D*o*c*u*m*e*n*t (the OP's MWE has this problem). If there is more text than mathematics in the nodes then use matrix of nodes instead of matrix of math nodes
  • I have set the default fill colour of the cells to green!20, assuming that this is the most common background
  • For the red cells I have overridden the default background with |[Red]| using the Red style
  • The empty node is used to control the (minimum) height of each of these nodes and to allow us to put a fat arrow there later
  • You can use east, west, south east, ... modifiers to control where the arrows leave and enter the nodes
  • The cells are of slightly different heights because of the different sizes of the subscripts. This is the reason for the specification of (M-2-2.east|-M-2-3.west) for the arrow from Document_f to Document_b. All this does is make the arrow perpendicular to the sides of the rectangle.
  • the Red, empty node and fat arrow styles make the code easier to read and easier to modify.
2

Not complet yet, but shows idea how to use multipart nodes:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,shapes.arrows,shapes.multipart}
    \begin{document}
%\begin{table}[!htb]
%    Interleaving example \\
    \begin{tikzpicture}[
    node distance=3mm and 9mm,
mytable/.style 2 args={name=mt#1,
    shape=rectangle split, draw=white, line width=2mm, 
    rectangle split parts=#2,
    text width = 33mm, font=\scriptsize,
    inner ysep=1mm, inner xsep=2mm, outer sep=0mm, align=left},
myArrow/.style={single arrow, draw=blue, fill=blue!30,
                minimum height=7mm,shape border rotate=90}
                        ],
\node[mytable={1}{3},fill=red!20]   
    {\nodepart{one}     Document$_a$
     \nodepart{two}     Document$_b$
     \nodepart{three}   Document$_c$
     };
\node[mytable={2}{4},
      rectangle split part fill={red!20,red!20,green!20,red!20},
      below right=0mm and 9mm of mt1.north east]
    {\nodepart{one}     Document$_a$
     \nodepart{two}     Document$_c$
     \nodepart{three}   Document$_b$
     \nodepart{four}    Document$_d$
     };
\node[myArrow,
      below=of mt1 |- mt2.south,
      label=below:Ranking A] {};
\node[myArrow,
      below=of mt2,
      label=below:Randomized] {};
\path[ultra thick, shorten >=1mm, shorten <=1mm,draw=gray,->]
    (mt1.one east) edge (mt2.one west)
    (mt1.two east) edge (mt2.three west)
    (mt1.three east) -- (mt2.two west);
\end{tikzpicture}
    \end{document}

enter image description here

names and arrows not follows your MWE.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .