1

I have this table:

\begin{center}
\renewcommand{\arraystretch}{1.5} % aumenta espaço entre linhas
\renewcommand{\tabcolsep}{18 pt}  % aumenta espaço entre colunas
\begin{tabular}{ c | c c | c }
\hline
& \multicolumn{2}{c|}{Y}\\
%\cline{2 - 4} % linha horizontal entre as colunas
% 2 e 4
X & 0 & 1 & Total \\
\hline
0 & $P_{00}$  & $P_{01}$ & $P_{0.}$ \\
1 & $P_{10}$ & $P_{11}$ & $P_{1.}$ \\
\hline
Total & $P_{.0}$ & $P_{.1}$ & 1 \\
\hline
\end{tabular}
\end{center}

enter image description here

I would like to draw left and right arrows in diagonal like the example picture (left and right arrows in diagonal P_00 to P_11 and P_10 to P_01)

Thanks

1
  • Welcome to tex.sx. Commented Nov 1, 2023 at 0:29

1 Answer 1

1

With use of the tikzmark library of tikzpackage:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{is/.style = {inner xsep=3pt}}

\begin{document}
    \[
    \renewcommand\arraystretch{1.5}
    \setlength\arraycolsep{18pt}
\begin{array}{ c | c c | c }
\hline
& \multicolumn{2}{c|}{Y}\\
X   & 0                             & 1                             & \mathrm{Total}    \\
\hline
0   & \tikzmarknode[is]{a}{P_{00}}  & \tikzmarknode[is]{b}{P_{01}}  & P_{0.} \\
1   & \tikzmarknode[is]{c}{P_{10}}  & \tikzmarknode[is]{d}{P_{11}}  & P_{1.} \\
\hline
\mathrm{Total}
    & P_{.0}                    & P_{.1}                      & 1 \\
\hline
\end{array}
    \]
\begin{tikzpicture}[overlay,remember picture]
  \draw[<->]   (a) -- (d);
  \draw[<->]   (c) -- (b);
\end{tikzpicture}
 
\end{document}

After at least two compilation you will get:

enter image description here

For shorten code in table body I use array instead of tabularray and insert it in math environment.

2
  • Perfect! Thank you, Zarko
    – flavio2f
    Commented Nov 1, 2023 at 3:30
  • @flavio2f, you are welcome! When you will sufficient reputation (15 or more) you can upvote answer, however you can already accept it (after while if you will not received answer which you will more liked).
    – Zarko
    Commented Nov 1, 2023 at 6:49

You must log in to answer this question.

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