I'm looking for a way to use a diagonal line to cross out a table cell which may or may not be empty, and without having to manually specify the cell's width and height. (It would also be great if the solution were compatible with tabu.)
That is, I want to find a definition of \strike
such that the following code produces the following output:
\documentclass{article}
\usepackage{tabu}
\newcommand{\strike}[1]{#1} % Some LaTeX wizardry here
\begin{document}
\renewcommand{\arraystretch}{2}
\begin{tabu}{|[3pt]c|c|c|[3pt]}
\tabucline[3pt]{-}
foo & bar & baz \\
\hline
\strike{quux} & A & B \\
\hline
C & D & \strike{$\delta$} \\
\tabucline[3pt]{-}
\end{tabu}
\end{document}
(I've found several previous Stack Exchange questions on diagonal lines through cells, but they all assume that the cell is of known dimensions, or that the cell is empty, or that the intention is to split the cell into two triangular cells with separate content. The "Strike out a table cell" question is probably closest to what I want, except that it's about striking out blank cells; it's not obvious to me how to adapt the solutions to striking out cells which already have content.)
Best Answer
Adapting from the answer you have linked I defined
\strike
. The command takes two arguments, which is due to the varying rules in your table.where
<column spec>
is the column format expected by\multicolumn
, e.g.|[3pt]c|
. You may specify columns different fromc
, but this will have no effect due to\hspace{0pt plus 1filll}
on both sides of the content.