Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 10 down vote accepted

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

share|improve this answer
    
Wow, great !! :-) –  Marco Dec 13 '12 at 14:27
    
One more question please... What would you change if I want the cross in two rows but one column (instead of two rows and two columns?) I guess the "connect" command has to change... –  Marco Dec 13 '12 at 14:34
    
No, why? You can use the TikZ anchors: I'll provide you a couple of examples. –  Claudio Fiandrino Dec 13 '12 at 14:42
    
Ok, I get it :-) Many Thanks! (+1) –  Marco Dec 13 '12 at 14:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.