[Tex/LaTex] Arrow with two colors with TikZ

graphicstikz-pgf

I want to create with TikZ a yellow arrow with black margin (border, edge).
I thought I could do this by using two arrows which lie on the top of each other, e.g. with:

\documentclass[12pt,twoside, a4paper]{report}
\usepackage{tikz} 
\begin{document}
\begin{tikzpicture}[yscale=0.25]%
\draw[->,black,very thick](-1974*0.107pt,119*0.107pt) -- (-2258*0.107pt,820*0.107pt);%first layer, black arrow
\draw[->,yellow,thick](-1974*0.107pt,119*0.107pt) -- (-2258*0.107pt,820*0.107pt);%second layer, yellow arrow
\end{tikzpicture}%
\end{document}

output of the code

But I am not so satisfied with the result because the black arrow should be a bit longer. I know I could play with the end point coordinates of the black arrow so that it fits well. But if I want to change the coordinates of my black-yellow arrow, this means I have to play again with the coordinates of the black arrow, which would cost a while.

Does anyone have a better solution? I would be glad to hear any hint.:-) Thanks in advance!

Best Answer

Edit 1: the new version of double arrow style requires three parameters: the global width and the two colors.

Here is a solution using postaction to define the new style double arrow (I use stealth arrows because doubled default arrows are not beautiful). The postaction option allows to redraw the arrow with different parameters (like shorten > to shorten the ending) :

enter image description here

\documentclass[margin=1mm]{standalone}
\usepackage{tikz}

\tikzset{
  double arrow/.style args={#1 colored by #2 and #3}{
    -stealth,line width=#1,#2, % first arrow
    postaction={draw,-stealth,#3,line width=(#1)/3,
                shorten <=(#1)/3,shorten >=2*(#1)/3}, % second arrow
  }
}

\begin{document}
\begin{tikzpicture}
\draw[double arrow=1pt colored by blue and white]
(0,2) -- (1,1) arc(45:-360+45+90:.5) -- (1.25,2);

\draw[double arrow=3pt colored by blue!50!black and lime,rounded corners]
(1.5,2)  -| (2,0);

\draw[double arrow=7pt colored by black and yellow]
(0,-.1) arc(120:60:.5) arc(-120:-60:.5) -- ++(30:.5);
\end{tikzpicture}%
\end{document}

Edit 2: I created other styles of double arrows: double -latex, double round cap-latex, double -stealth and double round cap-stealth (original double arrow and double -stealth are the same).

Firstly a small bunch:

second example

Then the code (with the four styles of double arrows):

\documentclass[margin=2mm]{standalone}
\usepackage{tikz} 
\usetikzlibrary{arrows}

\tikzset{
  double -latex/.style args={#1 colored by #2 and #3}{    
    -latex,line width=#1,#2,
    postaction={draw,-latex,#3,line width=(#1)/3,shorten <=(#1)/4,shorten >=4.5*(#1)/3},
  },
  double round cap-latex/.style args={#1 colored by #2 and #3}{    
    round cap-latex,line width=#1,#2,
    postaction={draw,round cap-latex,#3,line width=(#1)/3,shorten <=(#1)/4,shorten >=4.5*(#1)/3},
  },
  double round cap-stealth/.style args={#1 colored by #2 and #3}{
    round cap-stealth,line width=#1,#2,
    postaction={round cap-stealth,draw,,#3,line width=(#1)/3,shorten <=(#1)/3,shorten >=2*(#1)/3},
  },
  double -stealth/.style args={#1 colored by #2 and #3}{
    -stealth,line width=#1,#2,
    postaction={-stealth,draw,,#3,line width=(#1)/3,shorten <=(#1)/3,shorten >=2*(#1)/3},
  },
}

\begin{document}
\begin{tikzpicture}
\foreach \size [
evaluate=\size as \width using \size,
evaluate=\size as \bend using (\size-7)*5,
evaluate=\size as \angle using \size*36+180,
evaluate=\angle as \angleplushalf using \angle+18,
] in {1,2,...,10}{
  \draw[double round cap-stealth=\width pt colored by green!50!black and lime]
  (0,0) ++(\angle:1.2) to[bend right=\bend] ++(\angle:3);

  \draw[double round cap-latex=\width pt colored by black and yellow]
  (0,0) ++(\angleplushalf:1.2) to[bend right=\bend] ++(\angleplushalf:3);
}

\foreach \size [
evaluate=\size as \width using \size,
evaluate=\size as \bend using (\size-7)*5,
evaluate=\size as \angle using \size*36,
evaluate=\angle as \angleplushalf using \angle+18,
] in {1,2,...,10}{
  \draw[double -stealth=\width pt colored by blue!50!black and white]
  (0,-9) ++(\angle:1.2) to[bend right=\bend] ++(\angle:3);

  \draw[double -latex=\width pt colored by red and yellow]
  (0,-9) ++(\angleplushalf:1.2) to[bend right=\bend] ++(\angleplushalf:3);
}
\end{tikzpicture}%
\end{document}