It seems to be a bit tricky to draw outlined, transparent arrows between nodes in Tikz.
Here is my attempt at solving the simple case where the path is a straight, vertical line:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.arrows}
\begin{document}
\begin{tikzpicture}[
fat arrow/.style={draw,red,
every to/.style={
to path={
let \p1 = ($(\tikztotarget)-(\tikztostart)$),
\n2 = {veclen(\x1,\y1)} in
-- (\tikztotarget)
node[draw, blue, pos=.5, inner sep=0, text width=.2cm,
minimum height=\n2, single arrow, shape border rotate=270]
{} \tikztonodes}
}}]
\fill[yellow] (-.2,.5) rectangle (2.2,1.5);
\path (0,2) node[draw] (A) {A}
(0,0) node[draw] (B) {B}
(2,2) node[draw] (C) {C}
(2,0) node[draw] (D) {D}
;
\path[fat arrow] (A) to (B);
\path[fat arrow] (C.south) to (D.north);
\end{tikzpicture}
\end{document}
It gives this result:
But I would like the blue arrows to be exactly between the node boxes.
The path in red from A
to B
goes between the edges of the two nodes, but the height of the blue node on the "to" path is calculated from B.center - A.center
. Is there any "simple" way to fix this so that the arrow fits between the two nodes?
For the arrow between C
and D
, by adjusting the pos=.5
, I can fit the arrow exactly between the two nodes. Why is this necessary? Can the correct offset be calculated automatically?
Is there a "simple" way to set the value of shape border rotate
automatically?
pos=0.5
and setanchor=tip
.-- node[pos=.999,draw, blue, inner sep=1mm, anchor=tip, minimum height=\n2, single arrow,sloped]{} (\tikztotarget)