# Extending a tree

I am trying to extend the following tree, so that it is as in the picture:

\documentclass[12pt,a4paper]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usepackage{ulem}

\begin{document}

\begin{tikzpicture}
\Tree  [.DP E [.NP PRO [.NP $\lambda_1$ [.NP S  [.S [.DP [.D the ] [.N pictures ] ] [.VP  [.V display ] [.DP [.D the ] [.N man [. S   ]    ]]]]]]]]]]

\end{tikzpicture}

\end{document}

How can I do this?

Branches in the tree are just bracketed constituents in the bracketed structure. As a linguist you should be able to read bracketed structures as easily as trees, since since they are both used in the the field. Each pair of brackets is a constituent in the tree.

One way to make the debugging of complex trees much easier is to format them in your source using line breaks and tabs to show the structure. Then you can easily see the hierarchy as you want it to be.

It's also helpful to use an editor that shows bracket matching, (i.e., highlights in some way the opening bracket of a close bracket as you type it or select it.)

Here's how I would format your tree in the source: I've also added normalem to your \usepackage{ulem} line so otherwise all your emphasized text will be underlined instead of italics, which you likely don't want. And I've added some code to allow you to put terminal nodes on a new line below their node label without a branch, as this is linguistically correct, since the terminal node and its label are a single element.

\documentclass[12pt,a4paper]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\tikzset{every tree node/.style={align=center,anchor=north}}
\usepackage[normalem]{ulem}

\begin{document}

\begin{tikzpicture}
\Tree
[.S
[.DP E
[.NP PRO
[.NP $\lambda_1$
[.NP S
[.S
[.DP    [.D\\the ] [.N\\pictures ]]
[.VP    [.V\\display ]
[.DP [.D\\the ] [.NP [.N\\man ]
[.S   ]
]
]
]
]
]
]
]
]
[.VP [.V ] [.DP ]]
]

\end{tikzpicture}

\end{document}

Or you could use forest...

\documentclass[12pt,tikz,border=10pt]{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={child anchor=north, parent anchor=south}
[S [DP [E] [NP [PRO] [NP [$\lambda_1$] [NP [S] [S [DP [D [the]] [N [pictures]]] [VP [V [display]] [DP [D [the]] [N [man] [S]]]]]]]]] [VP [V] [DP]]]
\end{forest}

\end{document}

I originally adapted your code but Gonzalo Medina beat me to it. I did, however, beat him to the forest solution ;).

As Alan Munn explains, it can be helpful to layout the tree in a way which better reflects its structure. For example, I would probably write something more like this:

\begin{forest}
for tree={
child anchor=north,
parent anchor=south,
}
[S
[DP
[E]
[NP
[PRO]
[NP
[$\lambda_1$]
[NP
[S]
[S
[DP
[D
[the]
]
[N
[pictures]
]
]
[VP
[V
[display]
]
[DP
[D
[the]
]
[N
[man]
[S]
]
]
]
]
]
]
]
]
[VP
[V]
[DP]
]
]
\end{forest}

This makes it easier to see if you have the correct number of closing square brackets. Your editor may also help with this. For example, Kile shows me this:

which makes it easier to figure out where a particular sub-tree begins and ends, and whether any opening square brackets have not been closed.

One of the nice things about forest is that it is very easy to adapt your tree by modifying the preamble. For example, to neaten up the points at which the edges meet the nodes, we can set a standard height to be applied to all nodes. This allows us to keep the child anchor=north which centres the point at which the edge meets the node, while ensuring that the meeting points of different nodes on the same level are horizontally aligned:

\newlength\myheight
\settoheight\myheight{X}
\begin{forest}
for tree={
child anchor=north,
parent anchor=south,
text height=\myheight
}
[S
[DP
[E]
[NP
[PRO]
[NP
[$\lambda_1$]
[NP
[S]
[S
[DP
[D
[the]
]
[N
[pictures]
]
]
[VP
[V
[display]
]
[DP
[D
[the]
]
[N
[man]
[S]
]
]
]
]
]
]
]
]
[VP
[V]
[DP]
]
]
\end{forest}

If you want to keep the sense of separation between the subtrees shown in the target tree, you can add fit=rectangle to the first DP node:

Or fit=band which gives a similar result in this case:

Complete code for rectangular fit with aesthetic adjustments:

\documentclass[12pt,tikz,border=10pt]{standalone}
\usepackage{forest}

\begin{document}
\newlength\myheight
\settoheight\myheight{X}
\begin{forest}
for tree={
child anchor=north,
parent anchor=south,
text height=\myheight,
}
[S
[DP, fit=rectangle
[E]
[NP
[PRO]
[NP
[$\lambda_1$]
[NP
[S]
[S
[DP
[D
[the]
]
[N
[pictures]
]
]
[VP
[V
[display]
]
[DP
[D
[the]
]
[N
[man]
[S]
]
]
]
]
]
]
]
]
[VP
[V]
[DP]
]
]
\end{forest}
\end{document}