我正在借助forest
包裹。我的一些节点使用 TikZ 的rounded rectangle
样式(参见手册第 458 页)。
但是,这些节点的圆边重叠。我该如何解决这个问题?
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
point/.style={
coordinate,
},
symbol/.style={
draw=black,
text height=1.5ex,
text depth=.25ex,
},
terminal/.style={
symbol,
},
nonterminal/.style={
symbol,
rounded corners,
},
operation/.style={
symbol,
rounded rectangle,
},
[{Sequential},nonterminal
[{Sequential},nonterminal
[{$F_i$},operation]
[{$F_{i+1}$},operation]
]
[{},point
[{$F_{i+2}$},operation]]
]
\end{forest}
\end{document}
PS:我正在使用 TikZ v3。
答案1
这里描述的错误已在
forest
软件包的 v1.05 版本(2014/03/07)中修复。
似乎rounded rectangle
应用于某些节点的选项是包的问题forest
:将节点forest
的节点边界计算rounded rectangle
为rectangle
节点(仅使用north east
、north west
和south east
锚点south west
)。这是 中的一个错误forest
!
这是一个补丁forest
(也是针对您的问题的解决方案):
\documentclass{standalone}
\usepackage{forest}
% --------- patch -----------
\makeatletter
\csdef{forest@compute@node@boundary@rounded rectangle}{%
\forest@mt{east}%
\forest@lt{north east}%
\forest@lt{north}%
\forest@lt{north west}%
\forest@lt{west}%
\forest@lt{south west}%
\forest@lt{south}%
\forest@lt{south east}%
\forest@lt{east}%
}
\makeatother
% --------- end of patch -----------
\begin{document}
\begin{forest}
point/.style={
coordinate,
},
symbol/.style={
draw=black,
text height=1.5ex,
text depth=.25ex,
},
terminal/.style={
symbol,
},
nonterminal/.style={
symbol,
rounded corners,
},
operation/.style={
symbol,
rounded rectangle,
},
[{Sequential},nonterminal
[{Sequential},nonterminal
[{$F_i$},operation]
[{$F_{i+1}$},operation]
]
[{},point
[{$F_{i+2}$},operation]]
]
\end{forest}
答案2
您可以利用s sep
:
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={s sep=(2-level)*8mm}, %%% here
point/.style={
coordinate,
},
symbol/.style={
draw=black,
text height=1.5ex,
text depth=.25ex,
},
terminal/.style={
symbol,
},
nonterminal/.style={
symbol,
rounded corners,
},
operation/.style={
symbol,
rounded rectangle,
},
[{Sequential}, s sep=8mm,nonterminal %%% here
[{Sequential},nonterminal
[{$F_i$},operation]
[{$F_{i+1}$},operation]
]
[{},point
[{$F_{i+2}$},operation]]
]
\end{forest}
\end{document}