有没有办法在环境中从内径到外径画一个圆tikzpicture
?我想避免使用 pstricks,例如这个答案。
与本 MWE 类似,但无需绘制圆/节点乙多于A(添加不透明度 =.5 来显示圆 A 的“不需要的”内部部分):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{%
shapes.misc, % additional shapes, such as rounded rectangles
positioning, % advanced positioning
}
\begin{document}
\begin{tikzpicture}[%
roundnode/.style={circle, draw=black, fill=white, thick, inner sep=0em, opacity=1, fill opacity=1, draw opacity=1, font=\small},
]
\node[roundnode, minimum size=15mm, fill=red!20] (nodeA) at (1, 0) {};
\node[roundnode, minimum size=5mm, fill opacity=.5] (nodeB) at (1, 0) {B};
\end{tikzpicture}
\end{document}
答案1
您需要[even odd rule]
for \fill
。此外,您还需要节点的半径,即最小尺寸的一半。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{%
shapes.misc, % additional shapes, such as rounded rectangles
positioning, % advanced positioning
}
\begin{document}
\begin{tikzpicture}[%
roundnode/.style={circle, draw=black, fill=white, thick, inner sep=0em, opacity=1, fill opacity=1, draw opacity=1, font=\small},
]
\node[roundnode, minimum size=15mm] (nodeA) at (1, 0) {};
%\path (nodeA.north);
%\pgfgetlastxy{\xa}{\ya}
\node[roundnode, minimum size=5mm] (nodeB) at (1, 0) {B};
%\path (nodeB.north);
%\pgfgetlastxy{\xb}{\yb}
%\fill[even odd rule, red] (1,0) circle[radius=\yb] circle[radius=\ya];
\fill[even odd rule, red] (1,0) circle[radius=7.5mm] circle[radius=2.5mm];
\end{tikzpicture}
\end{document}