对于我试图构建树的图表,节点是圆圈。我需要一些节点用中心点标记(类似于textbullet
节点中心)。我想复制的图像是:
到目前为止我的树是:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[sibling distance = 2cm,
level 2/.style = {sibling distance = 1cm}]
\node[circle,draw]{}
child{ node[circle, draw]{}
child{ node[circle, draw]{}
child{ node[circle, draw]{}}
child{ node[circle, draw]{}}
}
child{ node[circle, draw]{}}
child{ node[circle, draw]{}}
}
child{ node[circle, draw]{}
child{ node[circle, draw]{}
child{ node[circle, draw]{}}
child{ node[circle, draw]{}}
}
};
\end{tikzpicture}
\caption{A tree}
\label{fig:tree}
\end{figure}
\end{document}
答案1
众多选项中,有三个。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[cc1/.style={circle,draw,node contents={\textbullet}},
cc2/.style={circle,draw,inner sep=0pt,minimum size=1cm,path picture={
\fill (0,0) circle[radius=2mm];},node contents={}}]
\path (0,0) node[circle,draw]{\textbullet}
(1,0) node[cc1] (2,0) node[cc2];
\end{tikzpicture}
\end{document}
答案2
新答案
child
您可以通过简单地编写而不是child{ node[circle, draw]{}}
创建适用于所有子项的样式来简化代码 :
every child node/.style={circle,draw,node contents=\textbullet}
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[sibling distance = 2cm,
level 2/.style = {sibling distance = 1cm},
every child node/.style={circle,draw,anchor=center,node contents=\textbullet}]
\node[circle,draw]{\textbullet}
child{
child{
child
child
}
child
child
}
child{
child{
child
child
}
};
\end{tikzpicture}
\caption{A tree}
\label{fig:tree}
\end{figure}
\end{document}
旧答案
像这样 ?
\documentclass[border=5mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=center,draw,circle] at (0,0) {\textbullet};
\end{tikzpicture}
\end{document}