4

How can I add an arrow between two tables?

enter image description here

    \documentclass[english]{IEEEtran}
    \usepackage{booktabs}

        \begin{document}

    \begin{table*}[!htb]

    \large\setlength{\tabcolsep}{0.1pt}
     \begin{minipage}{0.5\linewidth}
    \centering
    \caption{First Table}
    \label{tab:first_table}

   \medskip
    \begin{tabular}{ccc}
\toprule
\textbf{Start} & \textbf{Interval Time} & \textbf{Destination} \\
\midrule
Zone 1 & $483$ & Zone 2 \\
Zone 1 & $848$ & Zone 3  \\
Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
  Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
  Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
\bottomrule
   \end{tabular}   

    \end{minipage}\hfill
   \begin{minipage}{.5\linewidth}
 \centering

 \caption{Second Table}
  \label{tab:second_table}

\medskip

 \begin{tabular}{ccc}
\toprule
  \textbf{Start} & \textbf{Interval Time} & \textbf{Destination} \\
\midrule
Zone 1 & $483$ & Zone 2 \\
Zone 1 & $848$ & Zone 3  \\
Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
  Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
  Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
   \bottomrule
   \end{tabular}   
   \end{minipage}\hfill

    \end{table*}

   \end{document}
2

2 Answers 2

3

It is very simple, you need to add a \Rightarrow after your first table. Since I had time to do this, here it goes:

\begin{minipage}{0.5\linewidth}
\centering
\caption{First Table}
\label{tab:first_table}
 \medskip
\begin{tabular}{ccc}
\toprule
\textbf{Start} & \textbf{Interval Time} & \textbf{Destination} \\
\midrule
Zone 1 & $483$ & Zone 2 \\
Zone 1 & $848$ & Zone 3  \\
Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
Zone 1 & $121$ & Zone 4  \\
Zone 2 & $13$ & Zone 3 \\
\bottomrule
\end{tabular} 
\end{minipage}
$\Rightarrow$
8
  • 1
    it does not work. the second table comes below the first one
    – Mohamed
    Feb 14, 2019 at 6:10
  • @Mohamed You need to make your minipages a bit smaller, e.g. \begin{minipage}{0.45\linewidth}. This is why answers should always contain complete minimal working examples...
    – user121799
    Feb 14, 2019 at 6:12
  • I did it. it is still the same
    – Mohamed
    Feb 14, 2019 at 6:13
  • @marmot , I deleted the answer. How we can change the position of the arrow a little bit down
    – Mohamed
    Feb 14, 2019 at 6:28
  • 1
    @Mohamed ... \hfill\raisbeox{-3em}{$\Rightarrow$}\hfill ... . Could you do me a favor? Go back to all the answers you have received so far, and accept those which you found useful by clicking the check mark left of the corresponding answer. Thanks!
    – user121799
    Feb 14, 2019 at 6:38
5

With tikzmark, compile twice.

The arrow is in the (vertical) middle of the tables, headers included. the vertical alignment could be changed if you want it only in the middle of the table content, headers excluded.

I also made some improvement in the table layout (but I don't think >{$}c<{$} for numbers is needed at all).

\documentclass[english]{IEEEtran}
\usepackage{array}
\renewcommand{\arraystretch}{1.2}
\newcolumntype{C}{>{$}c<{$}}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{tikz}
\usetikzlibrary{tikzmark, shapes.arrows}
\usepackage{caption}

\begin{document}
    \begin{table*}
        \large
        \begin{minipage}{0.5\linewidth}
            \centering
            \caption{First Table}
            \label{tab:first_table}
            \tikzmarknode{A}{%contents
            \begin{tabular}{cCc}
                \toprule
                \textbf{Start} & \makecell{\textbf{Interval}\\ \textbf{Time}} 
                & \textbf{Destination} 
                \\
                \midrule
                Zone 1 & 483 & Zone 2 \\
                Zone 1 & 848 & Zone 3  \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                \bottomrule
            \end{tabular}}   
        \end{minipage}\hfill
        \begin{minipage}{.5\linewidth}
            \centering
            \caption{Second Table}
            \label{tab:second_table}
            \tikzmarknode{B}{%contents
            \begin{tabular}{ccc}
                \toprule
                \textbf{Start} & \makecell{\textbf{Interval}\\ \textbf{Time}} 
                & \textbf{Destination} 
                \\
                \midrule
                Zone 1 & 483 & Zone 2 \\
                Zone 1 & 848 & Zone 3  \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                \bottomrule
            \end{tabular}}   
        \end{minipage}
    \begin{tikzpicture}[remember picture, overlay]
    \path (A) -- node[draw, text width=3em, single arrow, thick, red]{} (B);
    \end{tikzpicture}   
    \end{table*}

\end{document}

enter image description here

Edit: The previous solution needs v1.6 from 2018/10/18 of tikzmark (or newest).

For users with older versions, here is a pure TikZ solution:

\documentclass[english]{IEEEtran}
\usepackage{array}
\renewcommand{\arraystretch}{1.2}
\newcolumntype{C}{>{$}c<{$}}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}

\begin{document}
    \begin{table*}
        \large
        \begin{minipage}{0.5\linewidth}
            \centering
            \caption{First Table}
            \label{tab:first_table}
            \tikz[remember picture]{\node[inner sep=0pt, outer sep=0pt](A){%contents
            \begin{tabular}{cCc}
                \toprule
                \textbf{Start} & \makecell{\textbf{Interval}\\ \textbf{Time}} 
                & \textbf{Destination} 
                \\
                \midrule
                Zone 1 & 483 & Zone 2 \\
                Zone 1 & 848 & Zone 3  \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                \bottomrule
            \end{tabular}}}   
        \end{minipage}\hfill
        \begin{minipage}{.5\linewidth}
            \centering
            \caption{Second Table}
            \label{tab:second_table}
            \tikz[remember picture]{\node[inner sep=0pt, outer sep=0pt](B){%contents
            \begin{tabular}{ccc}
                \toprule
                \textbf{Start} & \makecell{\textbf{Interval}\\ \textbf{Time}} 
                & \textbf{Destination} 
                \\
                \midrule
                Zone 1 & 483 & Zone 2 \\
                Zone 1 & 848 & Zone 3  \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                Zone 1 & 121 & Zone 4  \\
                Zone 2 & 13 & Zone 3 \\
                \bottomrule
            \end{tabular}}}   
        \end{minipage}
    \begin{tikzpicture}[remember picture, overlay]
    \path (A) -- node[draw, text width=3em, single arrow, thick, red]{} (B);
    \end{tikzpicture}   
    \end{table*}
\end{document}

enter image description here

11
  • 1
    I compile your answer. my output is completely different than yours. there is letter "A" besides the first table and "B" beside the second table. Also, the arrow in not centered
    – Mohamed
    Feb 14, 2019 at 18:11
  • @Mohamed Have you got an updated TeX distrubution? tikzmarknode is in the latest version of tikzmark, it does not work if you have a previous version.
    – CarLaTeX
    Feb 14, 2019 at 18:14
  • 1
    I am using overleaf.
    – Mohamed
    Feb 14, 2019 at 18:15
  • @Mohamed Overleaf has an old version. I'll update my answer to avoid tikzmark, wait a couple of hours, I have no time at the moment.
    – CarLaTeX
    Feb 14, 2019 at 18:21
  • great. do u know how to make captions of tables as in my question?
    – Mohamed
    Feb 15, 2019 at 2:31

You must log in to answer this question.

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