Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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}
share|improve this answer

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

share|improve this answer
    
This answer is a workaround of a bug in forest. –  Paul Gaborit Feb 23 at 9:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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