Graphics, Figures & TablesArrows at cells intersections

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mirou
Posts: 18
Joined: Thu Apr 29, 2010 4:36 am

Arrows at cells intersections

Post by mirou »

Hello there,

I have been looking for the following table to insert an arrow that links cell 13 with cell 16 and another that links cells 14 and 15 in the below table, so that these arrows come as a cross on cells intersections

Code: Select all

\begin{table}[!ht]
\caption{Composantes }
\label{Composantes }
\begin{center}
\begin{tabularx}{\linewidth}{|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|}
\hline
 \multicolumn{4}{|c|}{L'infrastructure}  \\
\hline
Niveau du SI & N1 & N2 & N3 \\
\cline {2-4}
& \textbf{Le matériel informatique et technologique} & \textbf{Les applications et solutions logicielles}  & \textbf{Les appropriations et utilisations}\\
\hline
Orientations de la flexibilité du SI  & Orientation vers une flexibilité de mission et de volume du matériel. & Orientation vers une haute standardisation des données & Fortes personnalisation des métiers du personnel, et agilité envers les clients.\\
\cline {3-4}
&& cell 13 & \textbf{\underline{OU}} cell 14\\
\hline
Orientations de la standardisation du SI & Orientation vers des règles de compatibilité et & cell 15 & cell 16 \\
\cline {3-4}
& d'intégration  & & Forte standardisation  \\
\hline
\end{tabularx}
\end{center}
\end{table}
Knowing that I mainly work under a thesis class
\documentclass[a4paper,12pt,twoside]{StyleThese} with many options under TexShop
and that I have checked the tikz package but find it a bit too advanced (complicated?) for me to use. I don't know how to name nodes and if these would work under tabularx environement??
Can anyone suggest a simple workaround for introducing these arrows pls?

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: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Arrows at cells intersections

Post by Stefan Kottwitz »

A TikZ way with \tikzmark, started from my example Highlighting elements in matrices:

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage{tikz}
\newcommand{\tikzmark}[2]{\tikz[remember picture,baseline=(#1.base)] \node (#1) {#2};}
\begin{document}
    \begin{table}[!ht]
    \caption{Composantes }
    \label{Composantes }
    \centering
    \begin{tabularx}{\linewidth}{|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|}
    \hline
     \multicolumn{4}{|c|}{L'infrastructure}  \\
    \hline
    Niveau du SI & N1 & N2 & N3 \\
    \cline {2-4}
    & \textbf{Le matériel informatique et technologique} & \textbf{Les applications et solutions logicielles}  & \textbf{Les appropriations et utilisations}\\
    \hline
    Orientations de la flexibilité du SI  & Orientation vers une flexibilité de mission et de volume du matériel. & Orientation vers une haute standardisation des données & Fortes personnalisation des métiers du personnel, et agilité envers les clients.\\
    \cline {3-4}
    && \tikzmark{cell13}{cell 13} & \textbf{\underline{OU}} \tikzmark{cell14}{cell 14}\\
    \hline
    Orientations de la standardisation du SI & Orientation vers des règles de compatibilité et & \tikzmark{cell15}{cell 15}& \tikzmark{cell16}{cell 16}\\
    \cline {3-4}
    & d'intégration  & & Forte standardisation  \\
    \hline
    \end{tabularx}
    \end{table}

\tikz[overlay,remember picture] {
  \draw[->,thick] (cell13) -- (cell16);
  \draw[->,thick] (cell14) -- (cell15);
}
\end{document}
You need to compile twice for correct placement.

Btw. in my opionion such grid tables don't show good design. Especially vertical lines are often discouraged. Have a look at real books or journals with good tables. Perhaps read the booktabs manual to learn more.
An better use \centering within a table or figure environment, not the center environment, see center vs. \centering.

Stefan
LaTeX.org admin
mirou
Posts: 18
Joined: Thu Apr 29, 2010 4:36 am

Arrows at cells intersections

Post by mirou »

Thanxs Stephan,

Your code compiles perfectly on a stand alone .tex file and gives my requested results. However when I try with inside thesis it does not.
the line code

Code: Select all

\newcommand{\tikzmark}[2]{\tikz[remember picture,baseline=(#1.base)] \node (#1) {#2};}
should be inserted in my FormatsAndDefs file or inside the chapter in which the table is inserted or in these.tex in which all thesis chapters and appendixes are included?

Also I think that once long text is inserted in place of the (cell number) the table behaves wiered. More specifically {cell13}{cell 13} in which one should my text go? I assumed the first is the label and the second is where my text should go but it did not..

Could you advise

Thanks for the booktab... I'm going through it and it does give good hints on how to deal (professionally) with vertical lines.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Re: Arrows at cells intersections

Post by Stefan Kottwitz »

That macro definition should be put into the preamble.

Regarding long text: the code is a start for you. Adjust it to your situation. If you cannot manage it, post a minimal example which matches yourt situation, i.e. with the right amount of text.

If it doesn't work in your thesis, test the small example with your thesis premable, or reduce a copy of the thesis with this macro to a minimal example, small but compilable and showing the problem.

Stefan
LaTeX.org admin
mirou
Posts: 18
Joined: Thu Apr 29, 2010 4:36 am

Arrows at cells intersections

Post by mirou »

Thanx once more Stefan. I have tried posting the macro in both the formats and definitions file and compiling or in the thesis preambule and compiling (several times), but still it did not work

I am attaching my formats and definitions .tex file and here is a the thesis preambule

Code: Select all

\documentclass[a4paper,12pt,twoside]{StyleThese}
\usepackage[fixlanguage]{babelbib}
\selectbiblanguage{french}
\usepackage{natbib}
\include{formatAndDefs}
\begin{document}
\reviewtimetoday{\today}{Draft Version}
\include{TitlePage}
\include{chapter1}

\end
and the table in the chapter with full text has the following code:

Code: Select all

\begin{table}[!ht]
    \caption{Composantes de l'infrastructure du système de travail d'un processus externalisé innovant et ses orientations}
    \label{tab:Composantes de l'infrastructure du système de travail d'un processus externalisé innovant et ses orientations}
    \centering
    \begin{tabularx}{\linewidth}{|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|}
    \hline
     \multicolumn{4}{|c|}{L'infrastructure du système de travail: Le SI}  \\
\hline
    Niveau du SI & N1 & N2 & N3 \\
    \cline {2-4}
    & \textbf{Le matériel informatique et technologique} & \textbf{Les applications et solutions logicielles}  & \textbf{Les appropriations et utilisations}\\
    \hline
Orientations de la flexibilité du SI  & Orientation vers une flexibilité de mission et de volume du matériel. & Orientation vers une haute standardisation des données & Fortes personnalisation des métiers du personnel, et agilité envers les clients.\\
    \cline {3-4}
    && Des applications c\oe urs flexibles avec & \textbf{\underline{OU}}  Des applications c\oe urs standardisées ce qui oblige\\
    \hline
    Orientations de la standardisation du SI & Orientation vers des règles de compatibilité et d'intégration & des utilisations  plus flexibles & des normes et règles de traitement des transactions plus standardisées. \\
    \cline {3-4}
    &   & & Forte standardisation pour une fiabilité des processus. \\
    \hline
    \end{tabularx}
    \end{table}
Really all what I was wishing for was arrows going like an X from a cell to another
Attachments
formatAndDefs.tex
(9.39 KiB) Downloaded 252 times
Last edited by cgnieder on Sun Mar 24, 2013 3:00 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Arrows at cells intersections

Post by Stefan Kottwitz »

Here I place the marks just somewhere within the longer cell text. In addition, I specified some shift values. You can adjust them as desired so that it fits.

Code: Select all

\documentclass[a4paper,12pt,twoside]{report}
\usepackage{tabularx}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand{\tikzmark}[2]{\tikz[remember picture,baseline=(#1.base)] \node (#1) {#2};}
\begin{document}
\begin{table}[!ht]
    \centering
    \begin{tabularx}{\linewidth}{|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1\hsize}X|}
        \hline
         \multicolumn{4}{|c|}{L'infrastructure du système de travail: Le SI}  \\
    \hline
        Niveau du SI & N1 & N2 & N3 \\
        \cline {2-4}
        & \textbf{Le matériel informatique et technologique} & \textbf{Les applications et solutions logicielles}  & \textbf{Les appropriations et utilisations}\\
        \hline
    Orientations de la flexibilité du SI  & Orientation vers une flexibilité de mission et de volume du matériel. & Orientation vers une haute standardisation des données & Fortes personnalisation des métiers du personnel, et agilité envers les clients.\\
        \cline {3-4}
        && Des applications c\oe urs \tikzmark{cell13}{}flexibles avec & \textbf{\underline{OU}}  Des applications \tikzmark{cell14}{}c\oe urs standardisées ce qui oblige\\
        \hline
        Orientations de la standardisation du SI & Orientation vers des règles de compatibilité et d'intégration & des utilisations  plus \tikzmark{cell15}{}flexibles & des normes et règles de \tikzmark{cell16}{}traitement des transactions plus standardisées. \\
        \cline {3-4}
        &   & & Forte standardisation pour une fiabilité des processus. \\
        \hline
    \end{tabularx}
\end{table}
\tikz[overlay,remember picture] {
  \draw[->,thick,dashed] (cell13) -- ([xshift=3em,yshift=-1ex]cell16.center);
  \draw[->,thick,dashed] (cell14) -- ([yshift=-3ex]cell15.center);
}
\end{document}
table.png
table.png (10.29 KiB) Viewed 4248 times
Stefan
LaTeX.org admin
Post Reply