我写下了这段代码:
\documentclass[border=10pt]{standalone}
%%%<
\usepackage{verbatim}
%%%>
\begin{comment}
:Title: A simple Tree
:Tags: Trees;Cookbook
:Author: L
:Slug: tree
A simple tree with a style for all nodes.
\end{comment}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
\node { (S , S)} child { node { (C , -)} child { node { (A , B)} child { node { (B , B)} child { node { (H , H)} child { node { (I , I)} } }child { node { (I , I)} }child { node { (H , H)} child { node { (I , I)} } } }child { node { (I , I)} }child { node { (H , H)} child { node { (I , I)} } } }child { node { (A , -)} child { node { (H , -)} child { node { (I , -)} } }child { node { (I , -)} }child { node { (H , -)} child { node { (I , -)} } } } } ;
\end{tikzpicture}
\end{document}
有重叠的节点,我该如何修复?
答案1
你喜欢吗?它是用fores
包装绘制的:
\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree={draw, semithick, rounded corners,
font = \sffamily,
top color = teal!10,
bottom color = teal!50,
grow = south,
s sep = 4mm, % sibling distance between nodes
l sep = 8mm, % level distance
}
[{(S , S)}
[{(C , -)}
[{(A , B)}
[{(B , B)}
[{(H , H)}
[{(I , I)}]
]
[{(I , I)}]
[{(H , H)}
[{(I , I)}]
]
]
[{(I , I)}]
[{(H , H)}
[{(I , I)}]
]
]
[{(A , -)}
[{(H , -)}
[{[I , -)}]
]
[{(I , -)}]
[{H , -)}
[{[I , -)}]
]
]
]
];
\end{forest}
\end{document}
解决方案tikz
已在您的问题下方的评论中给出。