1

I am new to using forest latex package. How to achieve expect result in LaTeX. How to move arrows in forest package?

My MWE is:

\documentclass{beamer}
\usepackage{qtree}
\usepackage[linguistics]{forest}
\useforestlibrary{linguistics}
\usetikzlibrary{shapes.geometric}
\usepackage{mathptm}

\forestset{
 sn edges/.style={for tree={parent anchor=south, child anchor=north}},
        background tree/.style={for tree={
            text opacity=0.8,draw opacity=0.8,edge={draw opacity=0.8}}}
}

\begin{document}
\centering
\begin{forest}
    [\textrm{CP},
        [\phantom{xxxxxxxxxxxxxxxxxxxx}\v{\!\!\!\d{c}}\hbox{'}al-$\textrm{ew}_{\textrm{i}}$\phantom{xxxxxxxxxxxxxxxxxxxx},name=spec CP]
            [$\textrm{C}^\prime$
                [\phantom{xxxxxxx}TP\phantom{xxxxxxx}
                    [\phantom{xxxxxxx}vP\phantom{xxxxxxx}
                        [\phantom{xxxxxxx}DP\phantom{xxxxxxx}
                            [$\textrm{Op}_{\textrm{i}}$,name=spec PC]
                            [PossP
                                [\!\!\!$_{-\!\!\!-\!\!\!-\!\!\!-\!\!\!-}{_{\textrm{PG}}}$ z-\v{s}, name=objects, roof]]]
                        [$\textrm{v}^\prime$
                            [\!\!\!$t_i({{\scriptstyle{\textrm{IO}}}}) \emptyset${-ze-r-j-t}, name=object, roof]]]
                    [T[-e]]]
                    [C${[{\scriptstyle{\textrm{WH}}}]}$]
            ]
    ]
    \draw[->] (object) to[out=south west,in=south] (spec CP);
    \draw[->] (objects) to[out=south west,in=south] (spec PC);
\end{forest}

\end{document}

Expected Result is enter image description here

1 Answer 1

3

Strictly speaking, drawing arrows is TikZ business, even when it is done in a Forest tree. And it is an art, I guess — chapters 13 and 15 of PGF/TikZ manual are the ultimate source of reference here, and the tutorials in that manual should help a lot as well.

Moving on to Forest business, there are two tricks one must use to arrive at the desired tree. The first one is simple: "fit=band" will create a node with nothing below it; when embedded in "for tree", as below, we get a "wide" tree. (Therefore, "for tree={fit=band}" eliminates the need for OP's phanom "xxx"s.)

The second trick is complicated. How do we get the outer arrow to shoot straight up after circling the DP subtree? If we do nothing about this, it will shoot slightly to the left, because "č'al-ew_i" is moved too much to the left — remember that the effect of "fit=band" is to leave the space below the node empty. The idea here is to typeset the tree with an empty node — below, I additionally remove (i) the inner x-space of that node and (ii) the "s sep"aration between the node and its sibling — and only later put in the desired content. To see how to draw the arrow itself, look at the (commented) code.

I took the liberty to clean up the code a bit as well. I removed the superfluous packages, used \textsubscript for text-mode subscripts, \textipa (from package tipa) for phonetic symbols and \textsc (small caps) for features.

\documentclass{beamer}
\usepackage[linguistics]{forest}
\usepackage{tipa}

\begin{document}
\centering
\begin{forest}
  for tree={
    plain content, % The linguistics library default has a little bug which results in some undesired space below each node. (The culprit is "align=center" in "default preamble".) Key "plain content" reverses that, but note that it only allows for single-line nodes.
    fit=band, % Removing this will result in a more compact tree.
  },
  [CP,
    [% \d{\v{c}}'al-ew\textsubscript{i},
      % We don't set the content of the node right away (it is commented out above), but rather pack the tree with this node empty --- which results in the center of "č'al-ew_i" being right above the west of Op_i --- and swap the empty node for the real node only just before drawing the tree.
      ,inner xsep=0, for parent={s sep=0}, before drawing tree={content=\d{\v{c}}'al-ew\textsubscript{i}, typeset node},
      name=spec CP,
      fit=band, % Strictly speaking, this is not necessary, it is only here so that if we remove the upper "fit=band", the arrow to spec-CP still shoots straight up.
    ]
    [C$^\prime$
      [TP
        [vP
          [DP
            [Op\textsubscript{i},name=Op] % text mode subscript
            [PossP
              [\textsubscript{\text{------PG}} \textipa{z@-\v{s}}, inner xsep=0, roof]
              % "---" = em dash
              {\draw[->] () to[out=south west,in=south] (Op);}
            ]
          ]
          [v$^\prime$
            [$t$\textsubscript{i}(\textsc{io}) $\emptyset$\textipa{-ze-r-j@-t@}, roof, inner xsep=0]
            {\draw[->,overlay]
              (.south west) % start at the bottom left of the node
              +(1.2em,0pt) % move a bit to the right, without drawing a line
              to[out=south,in=south,looseness=2]
              (Op.west) % loop to the west of Op_i, loosely ("looseness" sets two parameters, "in looseness" and "out looseness")
              -- (spec CP);}
          ]
        ]
        [T[\textipa{-Ke}]] % IPA
      ]
      [{C[\textsc{wh}]}] % small caps
    ]
  ]
\end{forest}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .