How do I draw a node with a double circle shape where one circle has a different color than the other circle?
A single \node[whatever] {content}
would be nice!
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityHere'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}
inner sep
to ensure that there is room for the inner circle. My reason for this is that with a double circle I would expect the node boundary to be on the outer circle, not the inner one.
Dec 2, 2011 at 7:45
inner sep
can't simply be accessed using \pgfkeysvalueof{/tikz/inner sep}
, so making this solution behave as you suggest isn't trivial. Feel free to edit this answer or add a new one if you come up with a way to make the outer circle the node border.
/pgf/inner xsep
(and /pgf/inner ysep
). I haven't tested it, though.
Dec 2, 2011 at 13:07
Not sure exactly what you want, but here are five different ways:
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Version 1
\draw [red ] (0,0) circle (5pt);
\draw [blue] (0,0) circle (10pt);
\node at (0,0) {1};
% Version 2
\node [draw=blue,double=red, circle, inner sep=1pt] at (1,0) {2};
% Version 3
\draw [draw=red, inner sep=1pt] (2,0) circle (8pt);
\node [draw=blue, circle, inner sep=1pt] at (2,0) {3};
% Version 4
\path (3,0) node [draw=red,shape=circle] {}
(3,0) node [draw=blue,shape=circle] {4};
% Version 5 (similar to Version 2)
\path (4,0) node [draw=blue, shape=circle, double=red] {5};
\end{tikzpicture}
\end{document}
draw
commands with \fill [blue] (0,0) circle (10pt);\fill [red ] (0,0) circle (5pt);
.
great job, I used your code to start a vertical timeline..
\usetikzlibrary[calc,arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,shapes,mindmap,shadows]
\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.8*\pgflinewidth}
in
node [inner sep=0.01pt, draw,circle, fill, minimum width=1*\n1,at=(\p1),#2] {}
}
},
double circle/.default={2.5pt}{blue!50}
}
\begin{tikzpicture}[
nonterminal/.style={rectangle,minimum size=6mm,very thick,draw=red!50!black!50,top color=white, bottom color=red!50!black!20,font=\itshape},
%{ The shape:, The size:, The border:, 50 % red and 50% black, and that mixed with 50% white, The filling:, a shading that is white at the top...,and something else at the bottom, Font}
terminal/.style={rectangle,minimum size=6mm,rounded corners=3mm,very thick,draw=black!50,top color=white,bottom color=black!20,font=\ttfamily},
line width=4pt,
circulo/.style={circle,minimum size=3mm,line cap=rect,draw=blue!50,top color=white,bottom color=blue!40,font=\ttfamily}
]
\node (A) [double circle, draw=blue!20] {};
\node (B) [double circle, draw=blue!20][below=of A] {};
\node (C) [double circle, draw=blue!20][below=of B] {};
\node (D) [double circle, draw=blue!20][below=of C] {};
\node (E) [double circle, draw=blue!20][below=of D] {};
\node (F) [double circle, draw=blue!20][below=of E] {};
\node (G) [double circle, draw=blue!20][below=of F] {};
\node (H) [double circle, draw=blue!20][below=of G] {};
\draw[-] [blue!20] (A) -- (H);
\node (B1) [rectangle, minimum size = 6mm][below=of A,label=right:Primeira Etapa, label=left:2008] {};
\end{tikzpicture}
`
) to mark inline code, as I did in my edit. Or, select the code and hit Ctrl + K.