2

I'm trying to figure out how to draw simple syntactic trees like the ones here, found in Heim & Kratzer's "Semantics & Generative Grammar." I do not want to include labels such as NP, VP, etc., and I will also need to be able to include more branching than in the examples shown here. Thanks for your help!

Example image

Stefan Kottwitz
  • 231,401
Elise
  • 45
  • 5
    I'm sorry but this is a question that will only make sense to a very tiny portion of the community here. The two major tree drawing packages tikz-qtree and forest both allow n-ary branching trees and arbitrary label text. (You will need to enclose the labels in {...} if they have more content). So perhaps you should try to reproduce a tree from Heim and Kratzer in a minimal document, add your attempt to your question and ask about what you are having trouble with specifically. – Alan Munn Sep 24 '16 at 20:48
  • @AlanMunn Or the OP could arrange for Amazon to mail all interested members of the site a copy. – cfr Sep 24 '16 at 22:30
  • 2
    @cfr Since I happen to have a copy of Heim and Kratzer handy, the question is even more mysterious since most of their trees have labels (although some are unlablelled) and all are binary branching. – Alan Munn Sep 24 '16 at 22:34
  • @AlanMunn Scotch my suggestion, then. Global distribution of the book to all TeX SE members doesn't sound as if it would help. – cfr Sep 24 '16 at 22:52
  • Also @cfr 's answer to this question: How do I make trees with straight skeletons or spines? should be helpful. – Alan Munn Sep 24 '16 at 23:03
  • @AlanMunn Is there an answer which might help using current Forest? My answer there doesn't use linguistics because it didn't exist at the time, but I'm not sure what about that answer you think helpful as I don't have the book. – cfr Sep 24 '16 at 23:39
  • @AlanMunn Ahh I'm so sorry! I thought I uploaded the screenshot of what I had in mind. I didn't realize it didn't go through. – Elise Sep 27 '16 at 20:33
  • 1
    Well code of what you had tried would have also been appreciated. But cfr and I seemed to be in a generous mood. :) But I assume our answers cover the cases you need.? – Alan Munn Sep 27 '16 at 20:53

2 Answers2

3

Since I happen to have a copy of Heim and Kratzer handy, your question is even more mysterious since most of their trees have labels (although some are unlablelled) and all are binary branching. Here's a tree using the forest package to get you started:

I've used the nice empty nodes style to allow labelless nodes, and created a pad style for nodes that are very small (like the 1 node). The calign with current addition to the DP node flattens the VP tree (without it, the tree looks quite ugly). [Thanks to cfr for that code.]

\documentclass{article}
\usepackage[linguistics]{forest}
\forestset{pad/.style={minimum width=5em}}
\begin{document}
\begin{forest}nice empty nodes
[S  
    [ {every linguist} ] 
    [ [1,pad ]  [S [ John ] 
                [   [T,pad ]  
                    [VP [V\\introduced ] 
                        [DP\\$t_{1}$,calign with current ] 
                        [PP\\{to Mary}]]]]]]
\end{forest}
\end{document}

output of code

Alternatively, if you don't mind how straight the empty node branches are, then you can use a slightly different definition for the empty nodes. This is probably better with non-binary trees. (And doesn't need the manual fixup in the DP node.)

\documentclass{article}
\usepackage[linguistics]{forest}
\forestset{pad/.style={minimum width=5em},
    empty nodes/.style={
            delay={where content={}{shape=coordinate,for parent={
                  for children={anchor=north}}}{}}
}}
\begin{document}
\begin{forest} empty nodes
[S  
    [ {every linguist} ] 
    [ [1,pad]  [S [ John ] 
                [   [T,pad]  
                    [VP [V\\introduced, ] 
                        [DP\\$t_{1}$ ] 
                        [PP\\{to Mary}]
                    ]]]]]
\end{forest}
\end{document}

output of code

Alan Munn
  • 218,180
  • 1
    (+1) For Forest 2. I'm not sure nice empty nodes is a good idea unless the tree is at least primarily binary branching. – cfr Sep 25 '16 at 00:27
2

'More branching' is ambiguous. You might mean that you need some nodes to have more than 2 children or you might mean that you just need more binary branches.

In the second case, just using the linguistics library with nice empty nodes will do a lot for your tree. In the first case, however, nice empty nodes will cause problems. If your tree is mostly binary, as in AlanMunn's example, then overriding its effects on an ad hoc basis is a reasonable option. If, however, it diverges much further, you are better off not using nice empty nodes here at all.

Here's an adaption of Alan's example which demonstrates the problem.

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[linguistics]{forest}
\forestset{pad/.style={minimum width=5em}}
\begin{document}
\begin{forest}
  nice empty nodes
  [S
    [{every linguist}
    ]
    [
      [1, pad
      ]
      [Additional thing]
      [Other thing]
      [S
        [ John
        ]
        [
          [T, pad
          ]
          [VP
            [V\\introduced
            ]
            [DP\\$t_{1}$, calign with current
            ]
            [PP\\{to Mary}
            ]
          ]
        ]
      ]
    ]
  ]
\end{forest}
\end{document}

not very binary

In this case, calign with current is not much help since we'll get either

no better

also no better

There are two problems here. One is that there are an even number of children so there is no middle child to align with the parent. The other is that the non-binary branching is not restricted to terminal nodes of the tree.

It might be better in such cases to try to make the empty nodes less ugly rather than nice. For example,

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[linguistics]{forest}
\forestset{%
  pad/.style={minimum width=5em},
  less ugly empty nodes/.style={%
    nice empty nodes,
    before typesetting nodes={%
      where={(n_children())>2}{%
        if={isodd(n_children())}{%
          for n={int((n_children()+1)/2)}{calign with current},
        }{%
          for n={int((n_children())/2)}{insert after={[,phantom,calign with current]}},
        },
        if nodewalk valid={uu}{%
          if={(n_children("!u")<3)&&(n_children("!uu")>2)}{!u.calign=midpoint}{},
        }{%
          if nodewalk valid=u{%
            !u.calign=midpoint,
          }{},
        },
      }{},
    },
  }
}
\begin{document}
\begin{forest}
  less ugly empty nodes
  [S
    [{every linguist}
    ]
    [
      [1, pad
      ]
      [Additional\\thing]
      [Other\\thing]
      [S
        [ John
        ]
        [
          [T, pad
          ]
          [VP
            [V\\introduced
            ]
            [DP\\$t_{1}$
            ]
            [PP\\{to Mary}
            ]
          ]
        ]
      ]
    ]
  ]
\end{forest}
\end{document}

less ugly empty nodes

This doesn't do too badly even with really quite crazy-looking trees.

quite crazy-looking tree

\begin{forest}
  less ugly empty nodes
  [S
    [{every linguist}
    ]
    [wants]
    [
      [1, pad
      ]
      [Additional\\thing]
      [Other\\thing]
      [S
        [ John
        ]
        [
          [T, pad
          ]
          [VP
            [V\\introduced
            ]
            [DP\\$t_{1}$
            ]
            [PP\\{to Mary}
            ]
          ]
        ]
      ]
    ]
    [to be
      [a]
      [philosopher
        [every philosopher
          [wants]
          [
            [to]
            [be]
            [a
              [mathematician]
            ]
          ]
        ]
      ]
    ]
  ]
\end{forest}

Ideally, I guess the code would test for craziness and adjust automatically. However, that answer would need a different and hopefully somewhat clearer question.

cfr
  • 198,882