# How do I cancel/strike out a line?

I have drawn a long line with an arrow from one node to another. How do I strike out or cancel that line? What I want is something similar to how \not cancels \to in A \not\to B, e.g.

Here's what I got so far and what I want to mimic:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node (a) {$$A$$};
\node (b) at (3,0) {$$B$$};
\draw[->] (a) to (b);% I want this line cancelled/striked out
\end{tikzpicture}

$$A \not\to B$$

\end{document}

-

You can use strike out from the shapes.misc tikz library.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\begin{document}

\begin{tikzpicture}
\node (a) {$$A$$};
\node (b) at (3,0) {$$B$$};
\draw[->] (a) -- node[strike out,draw,-]{} (b);% I want this line cancelled/striked out
\end{tikzpicture}

$$A \not\to B$$

\end{document}


This would be your modified code. And the result:

-
Both answers are good but I accepted this answer because it looks better in different directions and in conjunction with [bend left/right]. – N.N. Oct 14 '11 at 15:45

Not quite perfect perhaps.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node (a) {$$A$$};
\node (b) at (3,0) {$$B$$};
\node (c) at (3,3) {$$C$$};
\draw[->] (a) to node {$$\not$$} (b);
\draw[->] (a) to node [sloped] {$$\not$$} (c);
\end{tikzpicture}

$$A \not\to B$$

\end{document}


-
I like this slightly better than my answer, doesn't require a library and looks exactly like the \not\to as well. – Roelof Spijker Oct 13 '11 at 11:39
Can this be made to work properly when the line is not horizontal? E.g. when the coordinates of (b) is (3,3). – N.N. Oct 13 '11 at 11:50
Try adding sloped as an option to the \not node. I'll update the example shortly. – Torbjørn T. Oct 13 '11 at 11:52
@TorbjornT. Cheers! – N.N. Oct 13 '11 at 12:07