Curved double arrow in tikz?
This is just for fun. Both Raaja's answer and Symbol 1's answer are great. However, the paths in Raaa's answer are not precisely parallel, and the ones in Symbol 1's answer cannot be colored individually (at least not in an obvious way). So here is something that allows one to record paths and then parallel transport them and so on. This solution makes use of decorations, so for very curvy paths it can lead to dimension too large errors
, a limitation the above-mentioned answers do not have. This proposal can be used as follows. You need first to record the path, e.g.
\path[record path={name=AB}] (A) to[bend left] (B);
Then there will be two paths, one called top and the other bottom, which emerge from the above path by parallel transport. They can be reconstructed as follows:
\draw[-latex,reconstruct top=AB];
\draw[red,-latex,reconstruct bottom=AB];
Here is the full code with further examples, including a pattern between these paths. The only library that is needed for this stuff is decorations.markings
, patterns
and bending
are just for the examples and optics.
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings,patterns,bending}
\newcounter{parrow}
\tikzset{
record path/.style={
/utils/exec=\tikzset{parrow/.cd, #1},
decorate,
decoration={
markings,
mark=at position 0 with {
% init counter "parrow".
\setcounter{parrow}{1}
%\typeout{\pgfdecoratedpathlength}
% record coordinates (parrowt-<name>-1) and (parrowt-<name>-1).
\path
(0,\pgfkeysvalueof{/tikz/parrow/dist}/2) coordinate
(parrowt-\pgfkeysvalueof{/tikz/parrow/name}-\number\value{parrow})
(0,-\pgfkeysvalueof{/tikz/parrow/dist}/2) coordinate
(parrowb-\pgfkeysvalueof{/tikz/parrow/name}-\number\value{parrow});
% store step length (without unit) in \mystep globally.
\pgfmathsetmacro{\mystep}{(\pgfdecoratedpathlength-4pt)/int(1+(\pgfdecoratedpathlength-4pt)/2pt)}
\xdef\mystep{\mystep}
},
mark=between positions 2pt and 1 step \mystep pt with {
% for every step, record coordinates (parrowt-<name>-<parrow>) and (parrowb-<name>-<parrow>)
\stepcounter{parrow}
\path
(0,\pgfkeysvalueof{/tikz/parrow/dist}/2) coordinate
(parrowt-\pgfkeysvalueof{/tikz/parrow/name}-\number\value{parrow})
(0,-\pgfkeysvalueof{/tikz/parrow/dist}/2) coordinate
(parrowb-\pgfkeysvalueof{/tikz/parrow/name}-\number\value{parrow});
}
}
},
reconstruct top/.style={
% insert a path along recoreded coordinates (parrowt-<name>-<n>), where <n> = 1 to <parrow>
insert path={
plot[variable=\t, samples at={1,...,\number\value{parrow}}, smooth] (parrowt-#1-\t)
}
},
reconstruct bottom/.style={
% insert a path along recoreded coordinates (parrowt-<name>-<n>), where <n> = <parrow>-1 to 1
insert path={%
plot[variable=\t, samples at={\number\value{parrow}, \the\numexpr\value{parrow}-1,...,1}, smooth] (parrowb-#1-\t)
}
},
parrow area/.style={
% insert a closed path
insert path={
(parrowt-#1-1) [reconstruct top=#1] --
(parrowb-#1-\number\value{parrow}) [reconstruct bottom=#1] --
(parrowt-#1-1)
}
},
% init keys
parrow/.cd,
dist/.initial=3.14pt,
step/.initial=2pt,
name/.initial={}
}
\begin{document}
\begin{tikzpicture}[font=\sffamily, nodes={circle,draw}]
\path (0,0) node (A) {A}
(3,1) node (B) {B}
(3.2,-1) node(C) {C}
(5,0) node (D) {D};
% A to B
\path[record path={name=AB}] (A) to[bend left] (B);
\draw[-latex, reconstruct top=AB];
\draw[red, -latex, reconstruct bottom=AB];
% B to C
\path[record path] (B) to[out=-90,in=160] (C);
\path[pattern=north east lines, parrow area];
\draw[-latex, reconstruct top];
\draw[red, -latex, reconstruct bottom];
% C to D
\path[record path={name=CD, dist=5pt}] (C) to[bend left] (D);
\fill[yellow, parrow area=CD];
\draw[blue, -latex, reconstruct top=CD];
\draw[orange, -latex, reconstruct bottom=CD];
\end{tikzpicture}
\end{document}
A first possible approach based on: How do I make Tikz make a curved arrow from one node to another when my nodes are in a straight line? (see solution by erik
)
%&xelatex
% !TeX TXS-program:compile = txs:///xelatex/[--shell-escape]
\documentclass[convert={density=300,outext=.tiff}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',auto,node distance=3cm,
thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]
\node[main node] (1) {a};
\node[main node] (2) [right of=1, yshift = 2cm] {b};
\draw [->] (1) to [out=90,in=150] (2);
\draw [->,red] (2) to [out=160,in=80] (1);
\end{tikzpicture}
\end{document}
to get