Graphics, Figures & Tablesarrows in tabularx environment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
lkro
Posts: 2
Joined: Mon Sep 29, 2014 5:19 am

arrows in tabularx environment

Post by lkro »

Hello there!
My first post, so first: sorry for any etiquette errors. Actually I rarely need a lot of time to find solutions, the amount of information that people out there share is incredible... anyway, this time I got stock.

I have the following table:

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{pst-node}
\begin{document}

\begin{table}[h]
\begin{tabularx}{\linewidth}{ X X X }
\multicolumn{3}{l}{\textbf{Title}} \\
\hline
\small\textbf{I} & \small\textbf{II} & \small\textbf{III} \\

    \multirow{3}{*}{A} & 1 & \multirow{2}{*}{X}\\
    & 2 &						\\
    & 3 & \multirow{2}{*}{Y}		\\
    \multirow{3}{*}{B} & 4 & 	\\
    & 5 & \multirow{2}{*}{Z}	\\
    & 6 &\\

\end{tabularx}
\caption{Caption}\label{tab:danos}
\end{table}

\end{document}
So, it's basic with some minor tweaks. I'm trying to do the following: Have simple, black, default arrows pointing from cell A to 1, 2 and 3, from B to 3, 4, 5 and 6; from 1 - 3 to X, from 3 - 5 to Y and from 4-6 to Z. Zou get the point... I tried to adapt the pst-node (define the nodes, then \ncline...) solutions found in a great variety in the internets to my case. No luck. Don't know if I'm being stupid or lazy, which incompatibilities I might be overlooking....but I feel like giving up.

Any help?

Thanks a lot in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: arrows in tabularx environment

Post by Stefan Kottwitz »

Hi lkro,

welcome to the forum!

I would use TikZ for this, since I'm not so very experienced with PSTricks. Would you accept a Tikz solution?

Stefan
LaTeX.org admin
lkro
Posts: 2
Joined: Mon Sep 29, 2014 5:19 am

Re: arrows in tabularx environment

Post by lkro »

Would I accept that you help me? Of course!! (Unless you are implying that I should know something about compatibility etc. - which I don't. So let's try!)

Thanks!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

arrows in tabularx environment

Post by Stefan Kottwitz »

Here's a quick solution, I hope it's readable. \tm stands for "tikzmark" and sets markers using TikZ with a name. Later we use those for drawing arrows.

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{tikz}
\newcommand{\tm}[1]{\tikz[overlay, remember picture,
  baseline=(#1.base), anchor=west] \node [inner sep=0pt] (#1) {#1};}
\begin{document}
\begin{table}[ht]
\begin{tabularx}{\linewidth}{ X X X }
\multicolumn{3}{l}{\textbf{Title}} \\
\hline
\small\textbf{I} & \small\textbf{II} & \small\textbf{III} \\
    \multirow{3}{*}{\tm{A}} & \tm{1} & \multirow{2}{*}{\tm{X}}\\
    & \tm{2} &                                               \\
    & \tm{3} & \multirow{2}{*}{\tm{Y}}            \\
    \multirow{3}{*}{\tm{B}} & \tm{4} &    \\
    & \tm{5} & \multirow{2}{*}{\tm{Z}}    \\
    & \tm{6} &\\
\end{tabularx}
\caption{Caption}\label{tab:danos}
\begin{tikzpicture}[overlay, remember picture]
  \draw[->] (A) edge (1) edge (2) edge (3)
            (B) edge (3) edge (4) edge (5) edge (6)
            (3) edge (Y) (4) edge (Y) (5) edge (Y)
            (4) edge (Z) (5) edge (Z) (6) edge (Z);
\end{tikzpicture}
\end{table}
\end{document}
table.png
table.png (8.67 KiB) Viewed 6209 times
Stefan
LaTeX.org admin
Post Reply