对于 TikZ 中给定的树集,我遇到一个问题,即具有不同高度的节点(这里是一条线与两条线)与分离距离相冲突。以下是显示问题的图表:
\tikzstyle{every node}=[draw=gray, anchor=west]
\begin{tikzpicture}[%
grow via three points={one child at (0.5,-0.7) and %
two children at (0.5,-0.7) and (0.5,-1.5)},%
edge from parent path={(\tikzparentnode.south)%
|- (\tikzchildnode.west)}]
\node {root}
child {
node {A}
child {
node {One line}
}
child {
node {One line}
}
child {
node[text width = 25em] {Two\\lines}
}
};
\end{tikzpicture}
您有什么想法可以解决这个问题吗?
答案1
答案2
child
如果在你的两行子命令之后没有后续命令,那么你可以放心的改变grow via three points
那一个子命令的密钥:
\documentclass[tikz]{standalone}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=gray, anchor=west]
\begin{tikzpicture}[%
grow via three points={one child at (0.5,-0.7) and %
two children at (0.5,-0.7) and (0.5,-1.5)},%
edge from parent path={(\tikzparentnode.south)%
|- (\tikzchildnode.west)}]
\node {root}
child {
node {A}
child {
node {One line}
}
child {
node {One line}
}
child[grow via three points={one child at (0.5,-0.7) and two children at
(0.5,-0.7) and (0.5,-1.6)}] {
node[text width = 25em] {Two\\lines}
}
};
\end{tikzpicture}
\end{document}