2

I recently switched to tikz-qtree from qtree, but I run into two problems:

  1. The tree is asymmetrical.

  2. The reference (1) turns up at the bottom of the tree instead of the top

I am thankful for any suggestions?

\documentclass[12pt]{article}

\usepackage[swedish, english]{babel}
\usepackage{tikz-qtree-compat}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{covington}
\usepackage[natbibapa]{apacite}
\newcommand{\superscript}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\subscript}[1]{\ensuremath{_{\textrm{#1}}}}
\begin{document}

\begin{example} \label{tree12} 
\begin{tikzpicture}
\tikzset{every tree node/.style={align=center,anchor=north}}
\Tree [.vP 
        \qroof{Manne}.DP
        [ 
            [.\node(v){v\\vedt}; ]  
            [.ApplP 
                \qroof{maanide}.DP 
                [ 
                    [.\node(A){t{\scriptsize {\subscript {Appl}}}}; ] 
                    [.VP 
                        \node(V){t{\scriptsize {\subscript V}}}; 
                        \qroof{sijjen tjohph}.DP ] 
                            ] ] ] ] ]
\draw[semithick,->] (V)..controls +(south west:1) and +(south:1)..(A);
\draw[semithick,->] (A)..controls +(south west:4) and +(south:1)..(v);
\end{tikzpicture}
\end{example}

\end{document}

enter image description here

  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – Adam Liter Oct 2 '13 at 13:22
  • 1
    If you do \begin{tikzpicture}[baseline] instead of just \begin{tikzpicture}, that will solve your second problem. Could you clarify more what you mean about the tree being asymmetrical? I'm not sure I understand what you mean. If you're talking about the nodes with no labels branching differently, that is because you haven't given them any label, so the root goes directly to the branch of the next highest branch. I'm not sure that there is a way to avoid that, unless you give them a label like [.~ (instead of just doing [). This, however, creates some white space there. – Adam Liter Oct 2 '13 at 13:52
  • Also, another tip: assuming you're drawing a lot of trees, you can put \tikzset{every tree node/.style={align=center,anchor=north}} in the preamble so you don't have to write that for each tikzpicture. – Adam Liter Oct 2 '13 at 13:59
  • Thank you for your help! What I meant with asymmetric is what you thought. That the nodes with no labls branch differntly. I tried putting the piece of code you suggested in the blank nodes: .~ Anyway the lines don't connect and the tree still looks a bit "asymmetrical". – David Oct 3 '13 at 6:59
3

If you are open to using the forest package, I think you might get something closer to what you are looking for. The forest package tends to do a lot better job of aligning the nodes in trees, so I think you will get something that looks a bit more "symmetrical". The syntax is slightly different, and the package is also much more powerful than tikz-qtree. I would highly recommend reading the forest manual.

MWE

\documentclass[12pt]{article}

\usepackage{amsmath} % need for the \text command

\usepackage{forest}

\forestset{
% This style is defined on page 8 of the current forest manual
sn edges/.style={for tree={parent anchor=south, child anchor=north}},
% This style is defined on page 52 of the current forest manual
nice empty nodes/.style={for tree={calign=fixed edge angles},delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}

\usepackage[swedish, english]{babel}
\usepackage{covington}
\usepackage[natbibapa]{apacite}

\begin{document}

\begin{example}
\begin{forest}
sn edges, nice empty nodes, baseline
[vP, 
    [DP
        [Manne, triangle]
    ]
    [
        [v
            [vedt, triangle, name=vedt]
        ]
        [ApplP
            [DP
                [maanide, triangle]
            ]
            [
                [t$_{\text{Appl}}$, name=tappl]
                [VP
                    [t$_{\text{V}}$, name=tv]
                    [DP
                        [{sijjen tjohph}, triangle]
                    ]
                ]
            ]
        ]
    ]
]
\draw[semithick,->] (tv) [in=-90,out=-135,looseness=1] to (tappl);
\draw[semithick,->] (tappl) [in=-135,out=-90,looseness=2.5] to (vedt);
\end{forest}
\end{example}\label{tree12} 

\end{document}

Output

enter image description here

Explanation

The sn edges style that is defined globally using \forestset ensures that the branches connect at the base of a leaf (or node) of the tree.

The nice empty nodes style that is defined ensures that empty nodes do not result in white space in the tree; instead the branch of the tree continues right on down to the next leaf (or node).

The baseline option, as with a tikzpicture environment, ensures that the example number appears at the top of the tree, rather than the bottom of the tree.

  • Just saw your answer. Thanks alot! This will really help and I'll try it out right away. – David Oct 28 '14 at 13:09

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.