森林树木:圆角矩形节点重叠

森林树木:圆角矩形节点重叠

我正在借助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 rectanglerectangle节点(仅使用north eastnorth westsouth 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}

在此处输入图片描述

相关内容