使用时\node[circle, fit=(A) (B) (C)]
,生成的圆太大并且不接触C
节点的角:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\node[draw=blue] (A) at (30:1cm) {A};
\node[draw=blue] (B) at (150:1cm) {B};
\node[draw=blue] (C) at (270:1cm) {C};
\node[circle,draw=red,thick,fit=(A) (B) (C),inner sep=0pt] {};
\end{tikzpicture}
\end{document}
这似乎是因为 tikz 实际上正在围绕节点构建一个矩形以适应,然后在其外面绘制一个圆圈,如通过删除选项所见circle
:
如何在 Tikz 中将一个圆紧密地贴合在一组节点(可能超过 3 个)之外,而无需手动计算中心和大小?
答案1
和tkz-euclide
并且\tkzCircumCenter
;我留下了原始的拟合节点以便进行比较:
\documentclass{article}
\usepackage{tkz-euclide}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\node[draw=blue] (A) at (30:1cm) {A};
\node[draw=blue] (B) at (150:1cm) {B};
\node[draw=blue] (C) at (270:1cm) {C};
\node[circle,draw=red,thick,fit=(A) (B) (C),inner sep=0pt] {};
\coordinate (a) at (A.north east);
\coordinate (b) at (B.north west);
\coordinate (c) at (C.south east);
\tkzCircumCenter(a,b,c)
\tkzGetPoint{O}
\tkzDrawPoint(O)
\tkzDrawCircle[color=cyan](O,a)
\end{tikzpicture}
\end{document}