0

I am trying to create a table that has multiple strikes through columns and rows, similar to this table Table

I have tried this solution Striking thru a tabular row in LaTeX but it can't produce multiple strikes through. My code looked something like this

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{xfrac}
\usepackage{multirow}
\usepackage{cancel}

\usepackage{tikz} \tikzstyle{every picture}+=[remember picture] \tikzstyle{na} = [shape=rectangle,inner sep=0pt]

\newcommand{\myStrikeBegin}[1]{% \tikz[baseline=(begin.base)]\nodena{#1}; }

\newcommand{\myStrikeEnd}[1]{% \tikz[baseline=(end.base)]\nodena{#1}; \begin{tikzpicture}[overlay] \draw (begin.west) -- (end.east); \end{tikzpicture} } \begin{tabular}{cccc} 19 & \myStrikeBegin{0} & \myStrikeBegin{15} & 14 \ \myStrikeBegin{0} & 5 & 3 & \myStrikeEnd{0} \ 3 & 2 & 0 & 3\ 13 & \myStrikeEnd{20} & \myStrikeEnd{0} & 17 \end{tabular} \end{document}

And the result looked like this

myTable

(I wanted to strike through the 2nd and 4th columns as well as the 3rd row). I have tried to make 3 new similar commands but the resulting table is the same.

Is there any way to do it? Any help would be appreciated.

I. Farhan
  • 33
  • 3
  • @antshar I found that answer that using line tikz produces lines that is not entirely straight and setting out the new command is confusing for me. Maybe I am just not used to using tikz in that way – I. Farhan May 13 '22 at 14:16
  • 1
    @antshar After trying a couple of times, it seems that your link is indeed the answer. Thank you very much. At first, I was very skeptical that it works because it was applied to a matrix, not a table. But it works nonetheless, thanks again! – I. Farhan May 13 '22 at 14:43
  • You're welcome­ – antshar May 13 '22 at 14:48

1 Answers1

2

Just in case, this is very easy with pstricks:

    \documentclass[svgnames]{article}
    \usepackage{amsfonts}
    \usepackage{amsthm}
    \usepackage{mathtools}
    \usepackage{xfrac}
    \usepackage{multirow}
    \usepackage{cancel}
    \usepackage{pst-node}
    \usepackage{pst-eucl}
\begin{document}

\begin{table}
\begin{tabular}{cccc}
            19 & \Rnode{A}{0} & 15 & \Rnode{B}{14} \\
             0 & 5 & 3 & 0 \\
            \Rnode{C}{3} & 2 & 0 & \Rnode{D}{3}\\
            13 & \Rnode{E}{20} & 0 & \Rnode{F}{17}
\end{tabular}
\psset{linewidth=0.6pt, linecolor=LightSteelBlue}
\ncline[nodesepA=-1em, nodesepB=-1em]{A}{E}\ncline[nodesepA=-1em, nodesepB=-1em]{B}{F}\pstLineAB[nodesepA=1em, nodesepB=-1em]{C}{D}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
  • I have copied your code but it always produces error somehow. The errors are (Undefined control sequence) and (Undefined color) – I. Farhan May 13 '22 at 14:31
  • How did you compile? The classic wau is latex > dvi >dvips >pstopdf, becasue pdflatex doe not have the tools t make the computations trquired by postscript. Another way is compiling with xelatex --shell-escape. The ‘undefined color’ is strange, because pstricks loads xcolor, and I have set the option [svgnames] through the \documentclass. – Bernard May 13 '22 at 17:27