[Tex/LaTex] Triple lines in TikZ

tikz-pgftikz-styles

I need to be able to draw tripled paths in TikZ. I guess this could be done by some clever style which draws a big doubled path to get the outer curves correct, then uses some clever post-action hackery to draw a second non-doubled path to produce the central curve. I need to be able to set the thickness and the spacings of the three lines independently, just like one can with doubled lines.

Luckily, I don't need arrowheads on the line!

Anyone up to the challenge? 🙂

Best Answer

So basically a pre action on the path. I have added a style which is shown how to be called, notice that it will always draw.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
    triple/.style args={[#1] in [#2] in [#3]}{
        #1,preaction={preaction={draw,#3},draw,#2}
    }
}        
\begin{tikzpicture}
  \draw[triple={[line width=1mm,red] in
      [line width=2mm,blue] in
      [line width=4mm,black]}] (0,0) to[out=10,in=100] (0,1);
\end{tikzpicture}
\end{document}