[Tex/LaTex] cancelling out cells in tables

tables

Can you help me to obtain this table in LaTeX?

Is it possible to obtain it by completing the following code?

\begin{table}[htbp] \centering
\begin{tabular}{cccc}
\hline
a & b & c & d \\
e & f & g & h \\
i &   &   & j \\
k &   &   & l \\
\hline
\end{tabular}
\end{table}

enter image description here

Best Answer

A possible solution with the \tikzmark macro (requires two compilation runs):

\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[remember picture,overlay, baseline=-0.5ex]\node (#1){};}
\newcommand{\connect}[3][3mm]{\tikz[remember picture,overlay]\draw[shorten <=-#1, shorten >=-#1](#2)--(#3);}

\begin{document}
Cancelling two rows and two columns:
\begin{table}[htbp] \centering
\begin{tabular}{cccc}
\hline
a & b & c & d \\
e & f & g & h \\
i & \tikzmark{p1}  & \tikzmark{p2}  & j \\
k & \tikzmark{p3}  & \tikzmark{p4}  & l \\
\hline
\connect{p1}{p4}
\connect{p2}{p3}
\end{tabular}
\end{table}

Cancelling one row and two columns:
\begin{table}[htbp] \centering
\begin{tabular}{cccc}
\hline
a & b & c & d \\
e & f & g & h \\
i & \tikzmark{a1}  & \tikzmark{a2}  & j \\
\hline
\connect[1mm]{a1.north}{a2.south}
\connect[1mm]{a1.south}{a2.north}
\end{tabular}
\end{table}

Cancelling two rows and one column:
\begin{table}[htbp] \centering
\begin{tabular}{cccc}
\hline
a & b & c & d \\
e & f & g & h \\
i & \tikzmark{b1}  &  j & k\\
l & \tikzmark{b2}  & m & n\\
\hline
\connect[0mm]{b1.north west}{b2.south east}
\connect[0mm]{b1.north east}{b2.south west}
\end{tabular}
\end{table}

\end{document}

The result: enter image description here