# Positioning of trees

Consider

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

\begin{document}

X + Y $\Rightarrow$ \begin{tikzpicture} \Tree [.X X Y ] \end{tikzpicture}

\end{document}


Suppose I want X[...] and not X in the tree below. How can I insert it? How can I get X and Y to have <...> inserted just below them, in the way it has been done with A and B in p. 14-16 of these slides: http://www.ucl.ac.uk/~ucjtmgg/docs/cam-slides.pdf

How can I regulate the position of the tree? I would like to have the tree so that X + Y $\Rightarrow$ comes roughly in the middle of where the tree is, as in page 17 of the slides above:

The vertical placement of the figure can be done in many different ways. There is option baseline. Setting it to the center of the image (current bounding box.center) puts the middle on the current baseline of the surrounding text. The third example will show a way to center the image around the current math axis.

The second image puts the leafs on the same base line as the surrounding text.

The third image uses macro \VCenter to center the image around the math axis. The text before looks more like an equation. The centering is done via the TeX primitive \vcenter.

Additionally the nodes contain the angle brackets in a second line.

Full example:

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

\newcommand*{\VCenter}[1]{%
\ensuremath{%
\vcenter{%
\hbox{#1}%
}%
}%
}

\begin{document}

X + Y $\Rightarrow$
\begin{tikzpicture}[baseline=(current bounding box.center)]
\Tree [.X X Y ]
\end{tikzpicture}

\bigskip

\underline{X + Y $\Rightarrow$
\begin{tikzpicture}[baseline=(X.base)]
\Tree [.X \node(X){X}; Y ]
\end{tikzpicture}}

\bigskip

X + Y $\Rightarrow$
\VCenter{\begin{tikzpicture}[
every node/.append style={align=center},
level distance=50pt,
]
\Tree [ .\node{X\\$\langle\ldots\rangle$};
\node{X\\$\langle\alpha\rangle$};
\node{Y\\$\langle\beta\rangle$};
]
\end{tikzpicture}}

\end{document}


\documentclass[12pt,a4paper]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usepackage{stackengine}
\begin{document}
\raisebox{3\baselineskip}{X + Y $\Rightarrow$}
\tikzset{level 1/.style={level distance=60pt,sibling distance=30pt}}
\begin{tikzpicture} \Tree [.\stackunder{X}{$\langle$...$\rangle$}
\stackunder{X}{$\langle\alpha\rangle$} \stackunder{Y}{$\langle\beta\rangle$} ]
\end{tikzpicture}
\end{document}


A compact forest solution which uses baseline to set an empty node to the baseline of the tree.

\documentclass[12pt,a4paper]{article}
\usepackage{forest}
\begin{document}
X + Y $\Rightarrow$
\begin{forest}
for tree={align=center, parent anchor=south, child anchor=north, if n children=0{tier=t}{}}
[{X\\$[\dots]$} [{X\\$\langle\alpha\rangle$}] [, no edge, baseline [, phantom]] [{Y\\$\langle\beta\rangle$}] ]
\end{forest}
\end{document}