5

I am drawing a tree with the help of the forest package. Some of my nodes use TikZ's rounded rectangle style (see manual p.458).
However, the round sides of those nodes overlap. How do I fix that?

overlapping nodes

\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: I'm using TikZ v3.

8

The bug described here is fixed in version v1.05 (2014/03/07) of forest package.

It seems that the rounded rectangle option applied to some node is a problem with forest package: forest computes the node boundary of a rounded rectangle node as a rectangle node (using only north east, north west, south east and south west anchors). It is a bug in forest!

Here is a patch to forest (and a solution to your problem):

enter image description here

\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}
4

You can exploit 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}

enter image description here

  • This answer is a workaround of a bug in forest. – Paul Gaborit Feb 23 '14 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.