15

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.

What I want

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

Example of what I got

\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}
N.N.
  • 36,163

2 Answers2

12

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:

cancelled arrow

Roelof Spijker
  • 17,663
  • 5
  • 55
  • 63
  • 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
11

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}

enter image description here

Torbjørn T.
  • 206,688