Graphics, Figures & TablesCancelling a cell in a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

Cancelling a cell in a table

Post by yotama9 »

Hi.

How can I cancel a cell in laTeX? I searched google and wikibook and couldn't find any reference to this. I want to draw an X from the corners of the cell.

Also, is it possible to make a row a little higher? a superscript in a cell is to writing on the separating line of the table.

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Cancelling a cell in a table

Post by gmedina »

Hi,
yotama9 wrote:How can I cancel a cell in laTeX?...
There's a slashbox package that provides two commands \slashbox and \backslashbox to draw diagonal lines across a cell in a table. Some time ago I did some tests using this package and the results are really poor. Give it a try if you want, but don't expect nice results.

At this moment, I can only think of building the table and then using a package such as PGF/TikZ to manually place the diagonal lines.

Another option would be to buid everything using PGF/TikZ; take a look at the following simple example:

Code: Select all

\documentclass{book}
\usepackage{tikz-inet}
\usepackage{graphicx}
\usetikzlibrary{matrix}

\begin{document}
\begin{center}
\small
      \begin{tikzpicture}

    \matrix (magic) [%
      matrix of nodes,
      text width=4.1mm,text height=1mm,
      text badly centered
    ]
{%
0 & 40 & $-$ & 0\\
10 & 20 & 0 & 0\\
20 & 0 & 20 & $-$\\
10 & 0 & 40 & 40\\
    };
    % horizontal lines of the table
    \foreach \i in {1,2,3,4}
      \draw (magic-\i-1.north west) -- (magic-\i-4.north east);
    \draw (magic-4-1.south west) -- (magic-4-4.south east);
    % vertical lines of the table
    \foreach \j in {1,2,3,4}
      \draw (magic-1-\j.north west) -- (magic-4-\j.south west);
    \draw (magic-1-4.north east) -- (magic-4-4.south east);
    % the "X" shaped lines
    \draw (magic-2-3.north east) -- (magic-2-3.south west);
    \draw (magic-2-3.north west) -- (magic-2-3.south east);
  \end{tikzpicture}
\end{center}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply