[Tex/LaTex] TikZ, node with multiple lines around

circlesnodestikz-pgf

I want to draw a circle node using tikz that has more than two lines around. I found this question: TikZ – multi-color double circle node with its very good accepted answer. Unfortunately, I have no idea how to extend it to more than two lines.

Best Answer

You can use the style more than once:

\node [draw, double circle={2pt}{black!75},
             double circle={4pt}{black!50},
             double circle={6pt}{black!25}] (c1) {};

Or could nest them:

\node [draw,
       double circle={2pt}{black!75,
         double circle={2pt}{black!50,
           double circle={2pt}{black!25}}}] (c1) {};

Code

\documentclass[tikz] {standalone}
\usetikzlibrary{calc}

\tikzset{
    old inner xsep/.estore in=\oldinnerxsep,
    old inner ysep/.estore in=\oldinnerysep,
    double circle/.style 2 args={
        circle,
        old inner xsep=\pgfkeysvalueof{/pgf/inner xsep},
        old inner ysep=\pgfkeysvalueof{/pgf/inner ysep},
        /pgf/inner xsep=\oldinnerxsep+#1,
        /pgf/inner ysep=\oldinnerysep+#1,
        alias=sourcenode,
        append after command={
        let     \p1 = (sourcenode.center),
                \p2 = (sourcenode.east),
                \n1 = {\x2-\x1-#1-0.5*\pgflinewidth}
        in
            node [inner sep=0pt, draw, circle, minimum width=2*\n1,at=(\p1),#2] {}
        }
    },
    double circle/.default={2pt}{blue}
}
\begin{document}
\begin{tikzpicture}
\node [draw, double circle={2pt}{black!75},
             double circle={4pt}{black!50},
             double circle={6pt}{black!25}] (c1) {};
\node [draw, double circle={-2pt}{black!75},
             double circle={-4pt}{black!50},
             double circle={-6pt}{black!25}] (c2) at (2,0) {};
\end{tikzpicture}

\begin{tikzpicture}
\node [draw,
       double circle={2pt}{black!75,
         double circle={2pt}{black!50,
           double circle={2pt}{black!25}}}] (c1) {};
\node [draw,
       double circle={-2pt}{black!75,
         double circle={-2pt}{black!50,
           double circle={-2pt}{black!25}}}] (c2) at (2,0) {};
\end{tikzpicture}

Output

enter image description here

enter image description here

Related Question