6

I need to draws trees, in which one of the branches is squiggly, as showed in the screenshots below. Does anybody know how I can do that?

enter image description here

adapted from: Svenonius, P. (2015). Spanning. Ms., University of Tromso.

enter image description here

adapted from: Merchant, J. (2015). How Much Context Is Enough? Two Cases of Span-Conditioned Stem Allomorphy. Linguistic Inquiry, 46(2).

Thank you in advance!

RobertP.
  • 741
  • What do you have so far? The second diagram is not a tree at all. Any of the standard TikZ-based ways to draw a tree can do the squiggles. I assume the same is true for the pstricks approaches. If you really need generic graphs, you need a different approach, obviously. If you just need to add the odd edge here and there, you can draw it after the main tree using TikZ. tikz-qtree, forest, TikZ's built-in support for trees or the trees library. Or the graph-drawing stuff. Or .... – cfr Aug 24 '16 at 20:29

2 Answers2

12

I would, naturally, use Forest because I happen to like it. It is very powerful and extremely flexible. I would load it with the linguistics library defaults

\usepackage[linguistics]{forest}

use a TikZ library for the wiggly line

\usetikzlibrary{decorations.pathmorphing}

and define a couple of styles for convenience.

\forestset{%
  /tikz/squiggly/.style={decorate, decoration={snake, amplitude=.5mm, segment length=2mm}},

A TikZ style for wiggly lines.

  wiggly/.style={edge=squiggly},

A Forest style for wiggly edges.

  move me/.style n args=2{%
    before drawing tree={%
      x+=#1,
      y+=#2,
    },
  },

A Forest style for moving nodes to strange positions, overriding the locations calculated by the packing mechanism.

}

no edge can be used to block an edge and phantom can be used to create invisible nodes which just help with positioning.

Then the first tree can be drawn with

\begin{forest}
  [root
    [un, no edge]
    [dau, wiggly, no edge, move me={-5pt}{-20pt}]
    [tri, wiggly, move me={-10pt}{-40pt}]
    [pedwar, wiggly, move me={-15pt}{-60pt}]
    [, phantom, calign with current]
    [pump
      [chwech, roof]
    ]
  ]
\end{forest}

wiggly tree

Substituting the actual content

\begin{forest}
  [D\textsubscript{[+DEF,+F,-PL]}
  [\emph{un} <D\textsubscript{[-DEF,-F,-PL]}>, no edge, move me={200pt}{0pt}]
  [\emph{une} <D\textsubscript{[-DEF,+F,-PL]}>, wiggly, no edge, move me={100pt}{-20pt}]
  [\emph{le} <D\textsubscript{[+DEF,-PL]}>, wiggly, move me={60pt}{-40pt}]
  [\emph{la} <D\textsubscript{[+DEF,+F,-PL]}>, wiggly, move me={15pt}{-60pt}]
    [, phantom, calign with current]
    [NP
      [école, roof]
    ]
  ]
\end{forest}

produces

content into wiggly tree

The second diagram is not a tree, but it is a tree except for one edge, so I'd just use tikz to add the extra line.

          [I, tikz+={\draw [squiggly] (.parent anchor) -- (!sL.child anchor); }

To get the final nodes aligned, I would use tier and, since there's a regularity here, I'd add wiggly for all terminal nodes and use a phantom to prevent the single exception being aligned at the bottom of the tree.

Then

\begin{forest}
  where n children=0{
    wiggly,
    tier=terminus
  }{},
  [A
    [B
      [D
        [F
          [H
            [J
              [,phantom]
              [K]
            ]
          ]
          [I, tikz+={\draw [squiggly] (.parent anchor) -- (!sL.child anchor); }
            [,phantom]
          ]
        ]
        [G
          [L]
        ]
      ]
      [E
        [M]
      ]
    ]
    [C
      [N]
    ]
  ]
\end{forest}

will produce the second non-tree.

wiggly non-tree

Shamelessly plugging Alan Munn's content into the second structure above,

\begin{forest}
  where n children=0{
    wiggly,
    tier=terminus
  }{},
  [T
    [Asp
      [Voice
        [$v$
          [V
            [$\sqrt{\text{EAT}}$
              [,phantom]
              [fayo]
            ]
          ]
          [$v$, tikz+={\draw [squiggly] (.parent anchor) -- (!sL.child anchor); }
            [,phantom]
          ]
        ]
        [Voice\\\textminus act
          [o]
        ]
      ]
      [Aspect\\+perf
        [ik]
      ]
    ]
    [{T\\+past,1sg}
      [a]
    ]
  ]
\end{forest}

produces

shameless wiggly non-tree

Complete code:

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[linguistics]{forest}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{amsmath,textcomp}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\forestset{%
  /tikz/squiggly/.style={decorate, decoration={snake, amplitude=.5mm, segment length=2mm}},
  wiggly/.style={edge=squiggly},
  move me/.style n args=2{%
    before drawing tree={%
      x+=#1,
      y+=#2,
    },
  },
}
\begin{forest}
  [root
    [un, no edge]
    [dau, wiggly, no edge, move me={-5pt}{-20pt}]
    [tri, wiggly, move me={-10pt}{-40pt}]
    [pedwar, wiggly, move me={-15pt}{-60pt}]
    [, phantom, calign with current]
    [pump
      [chwech, roof]
    ]
  ]
\end{forest}
\begin{forest}
  [D\textsubscript{[+DEF,+F,-PL]}
  [\emph{un} <D\textsubscript{[-DEF,-F,-PL]}>, no edge, move me={200pt}{0pt}]
  [\emph{une} <D\textsubscript{[-DEF,+F,-PL]}>, wiggly, no edge, move me={100pt}{-20pt}]
  [\emph{le} <D\textsubscript{[+DEF,-PL]}>, wiggly, move me={60pt}{-40pt}]
  [\emph{la} <D\textsubscript{[+DEF,+F,-PL]}>, wiggly, move me={15pt}{-60pt}]
    [, phantom, calign with current]
    [NP
      [école, roof]
    ]
  ]
\end{forest}
\begin{forest}
  where n children=0{
    wiggly,
    tier=terminus
  }{},
  [A
    [B
      [D
        [F
          [H
            [J
              [,phantom]
              [K]
            ]
          ]
          [I, tikz+={\draw [squiggly] (.parent anchor) -- (!sL.child anchor); }
            [,phantom]
          ]
        ]
        [G
          [L]
        ]
      ]
      [E
        [M]
      ]
    ]
    [C
      [N]
    ]
  ]
\end{forest}    
\begin{forest}
  where n children=0{
    wiggly,
    tier=terminus
  }{align=center},
  [T
    [Asp
      [Voice
        [$v$
          [V
            [$\sqrt{\text{EAT}}$
              [,phantom]
              [fayo]
            ]
          ]
          [$v$, tikz+={\draw [squiggly] (.parent anchor) -- (!sL.child anchor); }
            [,phantom]
          ]
        ]
        [Voice\\\textminus act
          [o]
        ]
      ]
      [Aspect\\+perf
        [ik]
      ]
    ]
    [{T\\+past,1sg}
      [a]
    ]
  ]
\end{forest}
\end{document}
cfr
  • 198,882
  • 2
    align=center is standard with the linguistics library loaded. – Alan Munn Aug 24 '16 at 21:12
  • @AlanMunn Thanks. Corrected, I think. I'd either forgotten or never knew that. If you want me to delete the tree using your stolen content, let me know. I would completely understand. – cfr Aug 24 '16 at 21:19
  • 1
    No, that's fine. :) I actually like adding \phantom{x} nodes instead of just using phantom as it spaces out the multidominance lines a bit better. Your move-me code is very cool. – Alan Munn Aug 24 '16 at 21:22
  • @AlanMunn Yes, I noticed you did that, but I wasn't sure why. I'm not sure what multidominance lines are. (Cases where the child has more than one parent?) – cfr Aug 24 '16 at 21:24
  • 2
    Yes, exactly. For various types of linguistic analysis they are becoming more popular. They're horrible to draw however, in the general case. – Alan Munn Aug 24 '16 at 21:28
  • Thank you, @cfr! To clarify, I didn't mean to ask you to do it for me - I was actually wondering about the correct package to do that. – RobertP. Aug 25 '16 at 03:46
  • 3
    @RobertP. Fair enough. Usually when people post an image without code, they do seem to expect answers which just give them the code for the image. Note that even providing a document with just the content of the nodes makes it easier to help - especially if the content is from a discipline you're not familiar with. (That's why I stole Alan Munn's - he's a linguist. For me, the content has little meaning.) – cfr Aug 25 '16 at 12:07
  • @cfr: I was wondering how the coordinates of move me work. Can you clarify that to me? I have been trying to figure that out on my own, but I need some help. – RobertP. Oct 25 '16 at 03:05
  • @RobertP. They are just adjustments to the x and y coordinates which the node would normally have. The node just gets shifted horizontally and vertically by the given amounts. – cfr Oct 25 '16 at 03:08
  • so, I don't know why but my tree is too large and I can't figure out how to adjust it. How can I show what I mean? – RobertP. Oct 25 '16 at 03:26
  • @RobertP. You could edit your question, but it would probably be better to ask a follow-up question (i.e. a new question with a link to this one) or to ask in chat. [Assuming I've understood correctly that you're not having trouble with the original trees in this question but another tree.] – cfr Oct 25 '16 at 11:35
7

The first tree is barely a tree, and so you may want to draw it manually with a matrix of nodes. The second tree is fairly straightforward but needs some trickery to have the multidominance structure for the v structure since (as cfr correctly notes), multidominance 'trees' are not strictly speaking, trees.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\usepackage{amsmath}

\usepackage[linguistics]{forest}
\usetikzlibrary{snakes}
\tikzset{decoration={snake, amplitude=.4mm,segment length=2mm}}

\begin{document}

\begin{forest} where n children=0{tier=word, edge=decorate}{}
[T [Asp [Voice 
      [v [V\\$\sqrt{\text{\scshape eat}}$,name=V [\phantom{v},no edge]]
      [faɣo,no edge, name=Vroot] 
      [v,name=v [\phantom{v},no edge]]][Voice\\$-$act [θ]]]
   [Aspect\\$+$perf [ik]]] 
   [T\\{$+$past,1sg} [a]]]
\draw[decorate] (v.south) -- (Vroot.north);
\draw[decorate] (V.south) -- (Vroot.north);
\end{forest}

\end{document}

output of code

Alan Munn
  • 218,180
  • I don't understand why I didn't see your answer when I looked at this question, given that you posted it half an hour before mine. (I wouldn't have answered it if I'd known you'd already done so.) – cfr Aug 24 '16 at 21:22
  • @cfr No idea. And you solved the first part in a very clever way, so there's no real problem. – Alan Munn Aug 24 '16 at 21:24
  • Thanks. I like the \phantom{v} spacing. ... A bit of Welsh ;) – cfr Aug 24 '16 at 21:26
  • Also, I don't know why my answer has a vote more than yours. That doesn't seem fair. I'd vote for yours again if the system would let me - justice should be done! – cfr Aug 24 '16 at 21:31
  • @cfr Well yours does the first "tree", and mine doesn't. And yours doesn't have any extra \draw commands for the multidominance. And yours is just bigger! :) – Alan Munn Aug 24 '16 at 21:41
  • 1
    @cfr, if it makes you feel any better, I'll vote for Alan's and not yours, even though I think they both deserve upvotes! – Jason Zentz Aug 25 '16 at 13:24
  • @JasonZentz Now Alan's is listed first, it should get more votes anyway. (Plus the points for acceptance, of course.) – cfr Aug 25 '16 at 20:36