Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

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

share|improve this answer
    
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}

enter image description here

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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