# How can I strike-out arrows in tikz?

I am using the following code to draw a Directed Acyclic Graph (DAG) using tikz:

\usepackage{tikz}

\small{\begin{tikzpicture}[%
->,
shorten >=2pt,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {A};
\node[left=of 1] (2) {L};
\node[right=of 1] (3) {Y};
\draw [->] (2.east) -- (1.west);
\draw [->] (1.east) -- (3.west);
\draw [->] (2) to [out=15, in=165] (3);
\end{tikzpicture}}


I would like to be able draw a slash or strike-out through the arrow from L to A (the first arrow in the code) to indicate that the analysis method removes this association completely.

How can I modify the code to do this?

-
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important with tikz as there are so many libraries that could be used. –  Peter Grill Feb 6 at 2:35
Thanks for the heads up. I'll make sure to do that in the future. –  Azula R. Feb 6 at 3:26

One way which draws a diagonal line from the midpoint where the x and y is set via the macro \StrikeThruDistance as is shown by the red strike out.

You could also define a custom arrow as in the strike thru arrow style that I have defined below as shown by the blue arrow.

## Code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\newcommand*{\StrikeThruDistance}{0.15cm}%
\newcommand*{\StrikeThru}{\StrikeThruDistance,\StrikeThruDistance}%

\tikzset{strike thru arrow/.style={
decoration={markings, mark=at position 0.5 with {
\draw [blue, thick,-]
++ (-\StrikeThruDistance,-\StrikeThruDistance)
-- ( \StrikeThruDistance, \StrikeThruDistance);}
},
postaction={decorate},
}}

\begin{document}

\small{\begin{tikzpicture}[%
->,
shorten >=2pt,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {A};
\node[left=of 1] (2) {L};
\node[right=of 1] (3) {Y};
\draw [->] (2.east) -- (1.west);
% Manually draw the strike thru
\coordinate (MidWay) at ($(2.east)!0.5!(1.west)$);
\draw [thick, red,-] ($(MidWay)-(\StrikeThru)$) --
($(MidWay)+(\StrikeThru)$);
\draw [->, strike thru arrow] (1.east) -- (3.west);
\draw [->] (2) to [out=15, in=165] (3);
\end{tikzpicture}}
\end{document}

-

Manually it's possible to use another method :

1) I removed ->, shorten >=2pt because I think it's preferable to define a new style like pil

2) I determined a new coordinate mplaced at the middle of your arrow.

3) You can use the ($...$) facility or use the old way with shift. I used the two possibilities in the next example.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\small{\begin{tikzpicture}[%
>=stealth,
node distance = 1cm,
pil/.style    = { ->,
thick,
shorten =2pt}]
\node (1) {A};
\node[left=of 1] (2) {L};
\node[right=of 1] (3) {Y};
\draw [->] (2.east) -- coordinate (m) (1.west);
\draw[blue,shift={(m)}](-0.1,-0.1)--(0.1,+0.1);
\draw [->] (1.east) -- coordinate (m)(3.west);
\draw[red]($(m)+(-0.1,-0.1)$)--($(m)+(0.1,+0.1)$);
\draw [->] (2) to [out=15, in=165] (3);
\end{tikzpicture}}

\end{document}


-

This (presumably a duplicate) question offers an interesting alternative : just use a slash to typeset the strike-out.

The main advantage is the simplicity of the command, especially if the arrows are sloped and the strike-out need to be rotated accordingly. It comes at the expense of control over the look of the strike bar.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\begin{document}

\small{\begin{tikzpicture}[%
->,
shorten >=2pt,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {A};
\node[left=of 1] (2) {L};
\node[right=of 1] (3) {Y};
\draw [->] (2.east) -- (1.west) node[pos=0.5,red,sloped] {\tiny$/$};
\draw [->] (1.east) -- (3.west) node[pos=0.5,blue,sloped] {\tiny$/$};
\draw [->] (2) to [out=15, in=165] (3);
\end{tikzpicture}}

\end{document}


-