Here's a new style double circle
that can be supplied to a node. It takes two arguments, one for specifying how much larger the radius of the outer circle is (default is 2pt
), and the second for specifying the colour (or any combination of options, really) of the inner circle (default is blue
).
If you specify a node name, this will refer to the outer node (thanks to Andrew Stacey for the suggestion).
\node (A) [double circle, draw=red] {b};
\node (B) at (2,0) [draw, double circle={-2pt}{orange}] {ABC};
\draw (A) -- (B);
will give you
\documentclass[border=4mm] {standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\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{tikzpicture}
\node (A) [double circle, draw=red] {b};
\node (B) at (2,0) [draw, double circle={-2pt}{orange}] {ABC};
\draw (A) -- (B);
\end{tikzpicture}%
%
\end{document}
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
Best Answer
The node’s border is a path, you can use the same options for a
\path
, e.g.ultra thin
,thick
,very thick
, and so on:The
line width
key works as well:All predefined line widths are
Code
Output