1

Want to achieve something like this:

enter image description here

Code:

\usepackage[table]{xcolor}
\usepackage{forest}
\setlength{\arrayrulewidth}{.1mm}
\setlength{\tabcolsep}{12pt}
\renewcommand{\arraystretch}{2}
\arrayrulecolor[HTML]{AAAAAA}

\begin{document}
\begin{tabular}{c c}
    {
      \rowcolors{2}{white}{gray!20}
      \begin{tabular}{|c|c|}
        \hline
        TID & Items \\
        \hline
        1 & {a, b, e} \\
        2 & {a, b, c, d} \\
        3 & {a, c, d} \\
        4 & {a, c, e} \\
        5 & {b, c, } \\
        6 & {a} \\
        7 & {a, b, c} \\
        8 & {b, d, e} \\
        9 & {a, c} \\
        10 & {a, b, d, e} \\
        \hline

        \hline
        Item & Pointer \\
        \hline
        a & \\
        b & \\
        c & \\
        d & \\
        e & \\
        \hline
      \end{tabular}
    } & {
      \begin{tabular}{c c}
        \begin{forest}
          [null
            [a: 1
              [b: 1
                [e: 1]
              ]
            ]
          ]
        \end{forest}&
        \begin{forest}
          [null
            [a: 2
              [b: 2
                [e: 1]
                [c: 1
                  [d: 1]
                ]
              ]
            ]
          ]
        \end{forest}\\
      \end{tabular}
    }
  \end{tabular}
\end{document}

What it looks like:

enter image description here

Problem: Can't separate two tables. Can't put arrow between bottom table cells and graph nodes.

1

With tikzmark you have \tikzmarknodes for the table and \subnodes for the tree, which you can connect in an overlay tikzpicture (with remember picture).

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{forest}
\usetikzlibrary{tikzmark,arrows.meta,bending}
\setlength{\arrayrulewidth}{.1mm}
\setlength{\tabcolsep}{12pt}
\renewcommand{\arraystretch}{2}
\arrayrulecolor[HTML]{AAAAAA}

\begin{document}
\begin{tabular}{c c}
    {
      \rowcolors{2}{white}{gray!20}
      \begin{tabular}{|c|c|}
        \hline
        TID & Items \\
        \hline
        1 & {a, b, e} \\
        2 & {a, b, c, d} \\
        3 & {a, c, d} \\
        4 & {a, c, e} \\
        5 & {b, c, } \\
        6 & {a} \\
        7 & {a, b, c} \\
        8 & {b, d, e} \\
        9 & {a, c} \\
        10 & {a, b, d, e} \\
        \hline

        \hline
        Item & Pointer \\
        \hline
        \tikzmarknode{a}{a} & \\
        \tikzmarknode{b}{b} & \\
        c & \\
        d & \\
        e & \\
        \hline
      \end{tabular}
    } & {
      \begin{tabular}{c c}
        \begin{forest}
          [null
            [\subnode{a1}{a: 1}
              [\subnode{b1}{b: 1}
                [e: 1]
              ]
            ]
          ]
        \end{forest}&
        \begin{forest}
          [null
            [a: 2
              [b: 2
                [e: 1]
                [c: 1
                  [d: 1]
                ]
              ]
            ]
          ]
        \end{forest}\\
      \end{tabular}
    }\begin{tikzpicture}[overlay,remember picture,>={Stealth[bend]}]
    \draw[dashed,red,->] (a) -- ++ (2,0) to[out=0,in=180] (a1);
    \draw[dashed,red,->] (b) -- ++ (2,0) to[out=0,in=180] (b1);
\end{tikzpicture}%
  \end{tabular}
\end{document}

enter image description here

Or, if you wish to start these arrows in the pointer column.

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{forest}
\usetikzlibrary{tikzmark,arrows.meta,bending}
\setlength{\arrayrulewidth}{.1mm}
\setlength{\tabcolsep}{12pt}
\renewcommand{\arraystretch}{2}
\arrayrulecolor[HTML]{AAAAAA}

\begin{document}
\begin{tabular}{c c}
    {
      \rowcolors{2}{white}{gray!20}
      \begin{tabular}{|c|c|}
        \hline
        TID & Items \\
        \hline
        1 & {a, b, e} \\
        2 & {a, b, c, d} \\
        3 & {a, c, d} \\
        4 & {a, c, e} \\
        5 & {b, c, } \\
        6 & {a} \\
        7 & {a, b, c} \\
        8 & {b, d, e} \\
        9 & {a, c} \\
        10 & {a, b, d, e} \\
        \hline

        \hline
        Item & Pointer \\
        \hline
        a & \tikzmarknode{a}{\vphantom{b}}\\
        b & \tikzmarknode{b}{\vphantom{b}}\\
        c & \tikzmarknode{c}{\vphantom{b}} \\
        d & \tikzmarknode{d}{\vphantom{b}} \\
        e & \tikzmarknode{e}{\vphantom{b}} \\
        \hline
      \end{tabular}
    } & {
      \begin{tabular}{c c}
        \begin{forest}
          [null
            [\subnode{a1}{a: 1}
              [\subnode{b1}{b: 1}
                [e: 1]
              ]
            ]
          ]
        \end{forest}&
        \begin{forest}
          [null
            [a: 2
              [b: 2
                [e: 1]
                [c: 1
                  [\subnode{d2}{d}: 1]
                ]
              ]
            ]
          ]
        \end{forest}\\
      \end{tabular}
    }\begin{tikzpicture}[overlay,remember picture,>={Stealth[bend]}]
    \draw[dashed,red,->] (a) -- ++ (1.5,0)coordinate (aux) --
    ([xshift=1em]aux|-a1) -- (a1);
    \draw[dashed,red,->] (b) -- ++ (1.7,0) 
    coordinate (aux) -- ([xshift=1em]aux|-b1) -- (b1);
    \draw[dashed,red,->] (d) -- ++ (2.3,0) 
    coordinate (aux) -- ([xshift=5em]aux|-d2) -- (d2);
\end{tikzpicture}%
  \end{tabular}
\end{document}

enter image description here

And here is a version that does not use \tikzmarknode.

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{forest}
\usetikzlibrary{tikzmark,arrows.meta,bending}
\setlength{\arrayrulewidth}{.1mm}
\setlength{\tabcolsep}{12pt}
\renewcommand{\arraystretch}{2}
\arrayrulecolor[HTML]{AAAAAA}

\begin{document}
\begin{tabular}{c c}
    {
      \rowcolors{2}{white}{gray!20}
      \begin{tabular}{|c|c|}
        \hline
        TID & Items \\
        \hline
        1 & {a, b, e} \\
        2 & {a, b, c, d} \\
        3 & {a, c, d} \\
        4 & {a, c, e} \\
        5 & {b, c, } \\
        6 & {a} \\
        7 & {a, b, c} \\
        8 & {b, d, e} \\
        9 & {a, c} \\
        10 & {a, b, d, e} \\
        \hline

        \hline
        Item & Pointer \\
        \hline
        a & \tikzmark{a}\\
        b & \tikzmark{b}\\
        c & \tikzmark{c}\\
        d & \tikzmark{d}\\
        e & \tikzmark{e}\\
        \hline
      \end{tabular}
    } & {
      \begin{tabular}{c c}
        \begin{forest}
          [null
            [\subnode{a1}{a: 1}
              [\subnode{b1}{b: 1}
                [e: 1]
              ]
            ]
          ]
        \end{forest}&
        \begin{forest}
          [null
            [a: 2
              [b: 2
                [e: 1]
                [c: 1
                  [\subnode{d2}{d}: 1]
                ]
              ]
            ]
          ]
        \end{forest}\\
      \end{tabular}
    }\begin{tikzpicture}[overlay,remember picture,>={Stealth[bend]}]
    \draw[dashed,red,->] (pic cs:a) -- ++ (1.5,0)coordinate (aux) --
    ([xshift=1em]aux|-a1) -- (a1);
    \draw[dashed,red,->] (pic cs:b) -- ++ (1.7,0) 
    coordinate (aux) -- ([xshift=1em]aux|-b1) -- (b1);
    \draw[dashed,red,->] (pic cs:d) -- ++ (2.3,0) 
    coordinate (aux) -- ([xshift=5em]aux|-d2) -- (d2);
\end{tikzpicture}%
  \end{tabular}
\end{document}
| improve this answer | |
  • hmm.. I'm getting two errors saying No shape named a is known and No shape named b is known. It's like \tikzmarknode{a}{a} and \tikzmarknode{b}{b} are out of scope. – stackexchange_account1111 May 1 at 3:56
  • 1
    @stackexchange_account1111 Do you run the code from my answer as is? Is by chance your TeX installation not up to date? (The \tikzmarknode command has been added about a year ago or so.) – user194703 May 1 at 3:58
  • I'm using Texlive 2018. I guess that could be the culprit. It does also say Undefined control sequence a & \tikzmarknode. Thanks for the heads up! I'll upgrade and report back. – stackexchange_account1111 May 1 at 3:59
  • @stackexchange_account1111 The third part of the answer, which I just added, does not use \tikzmarknode. While this is no guarantee that this will work, it might. – user194703 May 1 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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