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}
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

1
  • 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

4
  • I like this slightly better than my answer, doesn't require a library and looks exactly like the \not\to as well. 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. Oct 13 '11 at 11:52
  • @TorbjornT. Cheers!
    – N.N.
    Oct 13 '11 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.