Search code examples
latextexoverleaf

How to draw a vertical arrow across the rows of the table in latex?


I want to create below table in latex. I have looked into the tikzlibrary but I was unable to find a solution to draw an arrow across a column in latex.enter image description here
Below is the code for generating the table in latex:

\begin{table*}
  \caption{Trend}
  \label{tab:trend}
  \begin{tabular}{cccl}
    \toprule
    Complexity Level & Mean Precision & MAP & NDCG \\
    \midrule
    1 & \parbox{2cm}{TFIDF: \\LSA: }  & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA:} \\\\
    2 & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA:} \\\\
    3 & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } \\\\
    4 & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } \\
  \bottomrule
\end{tabular}
\end{table*}

How can we draw a vertical arrow across the rows of the table in latex?


Solution

  • You can use the tikzmark library:

    \documentclass{article}
    
    \usepackage{booktabs}
    \usepackage{tikz}
    \usetikzlibrary{tikzmark}
    
    \begin{document}
    
    \begin{table*}
      \caption{Trend}
      \label{tab:trend}
      \begin{tabular}{cccl}
        \toprule
        Complexity Level & Mean Precision\tikzmark{foo} & MAP & NDCG \\
        \midrule
        1 & \parbox{2cm}{TFIDF: \\LSA: }  & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA:} \\\\
        2 & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA:} \\\\
        3 & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } \\\\
        4 & \parbox{2cm}{TFIDF: \\LSA: \tikzmark{bar}} & \parbox{2cm}{TFIDF: \\LSA: } & \parbox{2cm}{TFIDF: \\LSA: } \\
      \bottomrule
    \end{tabular}
    \begin{tikzpicture}[overlay,remember picture]
    \draw[->,blue,thick] (pic cs:foo) -- (pic cs:bar);
    \end{tikzpicture}
    \end{table*}
    
    
    \end{document}