3

I am using the fairly nice empty nodes-style from this question: Decrease distance between nodes in tree using Forest to make a tree with empty nodes that is smaller than what using nice empty nodes would generate. However, one node is only fairly nice. Is there a solution or is this the reason for using fairly as part of the name of the style.

\documentclass{minimal}
\usepackage{forest}

\forestset{
fairly nice empty nodes/.style={
            delay={where content={}{shape=coordinate,for parent={
                  for children={anchor=north}}}{}}
, angled/.style={content/.expanded={$<$\forestov{content}$>$}}
}}
\useforestlibrary{linguistics}
\forestapplylibrarydefaults{linguistics}


\begin{document}

\begin{forest} fairly nice empty nodes, for tree={l sep-=.2em,l=0}
[CP
    [C, fit=band]
    [TP
        [T, fit=band]
        [\textit{v}P
            [DP\\(EA), fit=band]
            [{}
                [VP
                    [DP\\(IA), fit=band]
                    [V]]                        
                [\textit{v}]]]]]
\end{forest}


\end{document}

The output is as follows. The problem is that the node branching to VP and v is branches a little too high, causing the tree to become slightly asymmetrical. What I like to achieve is a straight line between the node vP through the empty node and to the node v.

enter image description here

  • I'm not sure what you'd like to achieve. Maybe align EA and VP (and v)? – Sašo Živanović Aug 11 '16 at 11:39
  • Updated the question with a clarification. – David Kroik Aug 11 '16 at 12:09
  • Well, what are you prepared to sacrifice? You could let the tree be wider. You could have the angle at the grandparent be smaller. Etc. But if you want a smaller tree, something has to give, basically, in terms of the symmetry. Which do you want to give up? – cfr Aug 11 '16 at 21:42
4

The issue is what you are prepared to give up when you can't have everything. Having straight (or almost straight) lines makes the tree wider. Using fit=band makes the tree much wider.

fairly nice empty nodes sacrifices straight edges, by not keeping the angles between the edges constant. (It gives up calign=fixed edge angles.)

Another possibility is pretty nice empty nodes which sacrifices perfectly straight edges. (it gives up shape=coordinate.) However, with fit=band, this makes the tree very wide as that is the only way to keep the edges (almost) straight.

These styles are required because the tree cannot use nice empty nodes since that style turns out to require division by zero in this case, which TikZ can't do. However, nice empty nodes would also make the tree wide in conjunction with fit=band. So the fairly/pretty trade-off is not responsible for the mediocre-looking node in your tree. True, nice empty nodes would use straight edges, but with fit=band, the tree would end up very wide.

This is not a limitation of the software but due to the nature of reality itself. The constraint you are bumping against is a geometrical one and not a style or package one.

Here's one possibility using pretty nice empty nodes, which may not be what you want, but demonstrates how to create a compact tree with (almost) straight edges. What is sacrificed here is fit=band.

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage{forest}
\forestset{%
  pretty nice empty nodes/.style={
    for tree={
      calign=fixed edge angles,
      parent anchor=children,
      delay={if content={}{
          inner sep=0pt,
          edge path={\noexpand\path [\forestoption{edge}] (!u.parent anchor) -- (.children)\forestoption{edge label};}
        }{}}
    },
  }
}
\begin{document}
\begin{forest}
  pretty nice empty nodes,
  for tree={%
    l sep-=.2em,
    l=0,
    align=center,
  }
  [CP
    [C]
      [TP
        [T]
        [\textit{v}P
          [DP\\(EA)]
          [
            [VP
              [DP\\(IA)]
              [V]
            ]
            [\textit{v}]
          ]
        ]
      ]
    ]
\end{forest}
\end{document}

compact tree with almost straight edges

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.