我正在尝试连接 TikZ 中的子节点的末端。这些线形成了正确的形状(它应该看起来像一个三角形),但它们看起来有奇怪的位移。我希望这些线能够连接节点,而不是从图中显示出来。
当我注释掉 \tikz 行时,似乎问题就解决了。这是为什么?我该如何修复它,同时保持这种格式?
\begin{tikzpicture}
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\tikz [grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]
\node (root) {} child [color=\A, name = \A] foreach \A in {red,green,blue}
{ node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
{ node {}
}
};
\draw (root-1-1) -- (root-1-2) -- (root-1-3) -- (root-1-1);
\end{tikzpicture}
答案1
\begin{tikzpicture}
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\path [grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]%<------change \tikz to \path
node (root) {} child [color=\A, name = \A] foreach \A in {red,green,blue}
{ node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
{ node {}
}
};
\draw (root-1-1) -- (root-1-2) -- (root-1-3) -- (root-1-1);
\end{tikzpicture}