# Is it possible to place node on top of arrow?

Is it possible to change the output arrow in the code below so that it does not overlap the rectangle?

\documentclass[standalone]{article}

\usepackage{tikz}

\usetikzlibrary{positioning,decorations.markings,arrows}

\begin{document}

\begin{tikzpicture}[font=\small]
\tikzset{block/.style={draw, rectangle, line width=2pt, minimum height=3em,
minimum width=5em, outer sep=0pt}}

\tikzset{vecArrow/.style={
line width=1pt,
decoration={
markings,mark=at position 1 with {
\arrow[scale=2.5,line width=0.4pt] {open triangle 60}
}
},
double distance=4pt, shorten >= 13pt,
preaction = {decorate},
postaction = {draw,line width=4pt, white,shorten >= 10pt}
}}

\node [block] (A) {A};
\node[coordinate,right=2cm of A](B){};

\draw[vecArrow](A) -- node[above,align=center]{}(B);

\end{tikzpicture}

\end{document}

-

Two possible solutions:

1. You can load the backgrounds library, then enclose the arrow inside of \begin{scope}[on background layer] ... \end{scope}.

2. Alternatively, perhaps the best solution, you can add shorten <= \pgflinewidth, to your vecArrow style definition. The arrow will automatically shorten itself for the width of the node's border.

In both cases the result is the following:

-
Alternative 2 was the easiest. Thanks for your help. – Anders Mar 2 at 9:25

The simplest solution is to draw what goes on top at the very end. In this case, since you place nodes relative to other nodes, you can just "overwrite" what's been already drawn:

\documentclass[tikz, border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{
positioning,
decorations.markings,
arrows
}
\tikzset{
block/.style={
draw,
rectangle,
line width=2pt,
minimum height=3em,
minimum width=5em,
outer sep=0pt
},
vecArrow/.style={
line width=1pt,
decoration={
markings,
mark=at position 1 with {
\arrow[scale=2.5,line width=0.4pt] {open triangle 60}
}
},
double distance=4pt,
shorten >=13pt,
preaction={decorate},
postaction={
draw,
line width=4pt,
white,
shorten >= 10pt
},
},
}
\begin{document}
\begin{tikzpicture}[font=\small]
\node [block] (A) {};
\node [coordinate, right=2cm of A] (B) {};
\draw[vecArrow](A) -- (B)
node [pos=1, anchor=west] {Anders};
\node [block] at (A) {A};
\end{tikzpicture}

\end{document}


Also, it is possible to place a node at the end of a \draw command as demonstrated above.

-

You can draw paths before your node is inked via append after command.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,decorations.markings,arrows}

\begin{document}

\begin{tikzpicture}[font=\small]
\tikzset{block/.style={draw, rectangle, line width=2pt, minimum height=3em,
minimum width=5em, outer sep=0pt}}

\tikzset{vecArrow/.style={
line width=1pt,
decoration={
markings,mark=at position 1 with {
\arrow[scale=2.5,line width=0.4pt] {open triangle 60}
}
},
double distance=4pt, shorten >= 13pt,
preaction = {decorate},
postaction = {draw,line width=4pt, white,shorten >= 10pt}
}}

\draw[vecArrow]
node [block,append after command={coordinate[right = 2cm of A] (B) {(A) -- (B)}}]
(A) {A};

\end{tikzpicture}
\end{document}


this gives the same picture given in other answers

-