summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex')
-rw-r--r--Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex98
1 files changed, 91 insertions, 7 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex b/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex
index 46c795fb1c7..88f91b7d2eb 100644
--- a/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex
+++ b/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex
@@ -19,9 +19,11 @@
\newcommand\tikztree{\texttt{tikz-qtree}}
+\tikzset{>=latex}
+
\title{\tikztree: better trees with TikZ}
\author{David Chiang}
-\date{Version 1 (22 Dec 2009)}
+\date{Version 1.1 (Christmas 2009)}
\begin{document}
@@ -70,9 +72,8 @@ below require the explicit \verb|tikzpicture| environment.
\paragraph{Options} Some options for standard TikZ trees work for \verb|\Tree| as
well:
\begin{itemize}
-\item \verb|level distance|: vertical distance between the anchors of a parent and child
+\item \verb|level distance|: vertical distance between the anchors of a parent and its children
\item \verb|sibling distance|: horizontal distance between the boundaries of sister subtrees (not the anchors of their roots, as in standard TikZ trees). Note that TikZ nodes already have some horizontal space around them (\verb|inner xsep|, by default \verb|0.3333em|), so even \verb|sibling distance=0pt| leaves some room.
-\item \verb|grow=up| or \verb|down|: trees grow up or down from their root. Other directions are not currently supported. The \verb|grow'| option is the same, but children appear clockwise with respect to their parent instead of counterclockwise.
\end{itemize}
These are set either by writing
\verb|\tikzset{|\textit{option}\verb|=|\textit{value}\verb|}| or by
@@ -88,11 +89,33 @@ no way to disambiguate the two uses of square brackets.} For example:
\Tree [.NP [.Adj tall ] [.N tree ] ]
\end{tikzpicture}
%
+\begin{tikzpicture}[sibling distance=72pt]
+\Tree [.NP [.Adj fat ] [.N tree ] ]
+\end{tikzpicture}
+\end{SideBySideExample}
+\end{center}
+
+The \verb|grow=|\textit{direction}\/ and \verb|grow'=|\textit{direction}\/ options control the orientation of trees just as for standard TikZ trees. However, \textit{direction}\/ must be one of \verb|up|, \verb|down|, \verb|left|, or \verb|right|. The difference between \verb|grow| and \verb|grow'| is that \verb|grow| places children counterclockwise with respect to their parent and \verb|grow'| places them clockwise:
+\begin{center}
+\begin{SideBySideExample}
+\begin{tikzpicture}[grow'=down]
+\Tree [.NP [.Adj reverse ] [.N tree ] ]
+\end{tikzpicture}
+%
\begin{tikzpicture}[grow'=up]
\Tree [.NP [.Adj upside-down ] [.N tree ] ]
\end{tikzpicture}
\end{SideBySideExample}
+\vspace{3ex}
+\begin{SideBySideExample}
+\begin{tikzpicture}[grow=left]
+\tikzset{level distance=60pt,sibling distance=18pt}
+\tikzset{execute at begin node=\strut}
+\Tree [.NP [.Adj sideways ] [.N tree ] ]
+\end{tikzpicture}
+\end{SideBySideExample}
\end{center}
+Note that in sideways trees, \verb|level distance| is horizontal and \verb|sibling distance| is vertical. Sideways trees do take a little extra adjusting to look right, since the defaults are geared towards vertically growing trees. The meaning of the option \verb|execute at begin node=\strut| is, before typesetting the label of every node, insert the command \verb|\strut|, which is an invisible box that maximizes the height and depth of the node.
\paragraph{Styles} TikZ lets you define \emph{styles}\/ which encapsulate multiple options:
\begin{Verbatim}
@@ -136,14 +159,46 @@ this font:
\end{tikzpicture}
\end{SideBySideExample}
\end{center}
-If you want the edges to be darker:
+
+You can make the nodes in a sideways tree line up on their left edge using \verb|anchor=base west|:
+\begin{center}
+\begin{SideBySideExample}
+\begin{tikzpicture}
+\tikzset{grow'=right,level distance=32pt}
+\tikzset{execute at begin node=\strut}
+\tikzset{every tree node/.style={anchor=base west}}
+\Tree [.S [.NP [.Det the ] [.N cat ] ]
+ [.VP [.V sat ]
+ [.PP [.P on ]
+ [.NP [.Det the ] [.N mat ] ] ] ] ]
+\end{tikzpicture}
+\end{SideBySideExample}
+\end{center}
+
+In Qtree, it was allowed to use a line break (\verb|\\|) inside a node, but TikZ nodes by default don't allow this. You can enable it like so:
+\begin{center}
+\begin{SideBySideExample}
+\begin{tikzpicture}
+\tikzset{every tree node/.style={text width=2em,text centered}}
+\Tree [.S [.NP Det\\the N\\cat ]
+ [.VP V\\sat
+ [.PP P\\on
+ [.NP Det\\the N\\mat ] ] ] ]
+\end{tikzpicture}
+\end{SideBySideExample}
+\end{center}
+The downside is that you must specify a fixed node width. In the next release of TikZ, it will be possible to use instead a new \verb|align=center| option without the fixed width.\footnote{Thanks to Alan Munn for figuring this out.}
+
+You can also define a style for all the edges in a tree. For example, if you want the edges to be a little darker:
\begin{center}
\begin{SideBySideExample}
+\begin{tikzpicture}
\tikzset{edge from parent/.style={draw,thick}}
\Tree [.S [.NP [.Det the ] [.N cat ] ]
[.VP [.V sat ]
[.PP [.P on ]
[.NP [.Det the ] [.N mat ] ] ] ] ]
+\end{tikzpicture}
\end{SideBySideExample}
\end{center}
The \verb|draw| option is necessary, as by default they will not be
@@ -154,6 +209,7 @@ the edge. Its value is a TikZ path expressed in terms of
the child node.
\begin{center}
\begin{SideBySideExample}
+\begin{tikzpicture}
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
@@ -163,6 +219,7 @@ the child node.
[.VP [.V sat ]
[.PP [.P on ]
[.NP [.Det the ] [.N mat ] ] ] ] ]
+\end{tikzpicture}
\end{SideBySideExample}
\end{center}
@@ -183,7 +240,6 @@ the appearance of the node; for example, the \verb|draw| option draws
a border around the node. The \verb|(|\textit{name}\verb|)|, which is
also optional, can be used for drawing lines/arrows to/from the node.
\begin{center}
-\tikzset{>=latex}
\begin{Example}
\begin{tikzpicture}
\Tree [.CP [.NP \node(wh){what}; ]
@@ -200,7 +256,25 @@ also optional, can be used for drawing lines/arrows to/from the node.
\end{Example}
\end{center}
-\clearpage
+You can also refer to the whole subtree rooted at the node named \textit{name}\/ using \verb|\subtreeof{|\textit{name}\verb|}|:
+\begin{center}
+\begin{SideBySideExample}
+\begin{tikzpicture}
+\Tree [.S [.NP [.Det the ] [.N cat ] ]
+ [.\node(site){VP}; [.V sat ] ] ]
+\begin{scope}[shift={(1in,0.5in)}]
+\Tree [.\node(root){VP}; VP$^\ast$
+ [.PP [.P on ]
+ [.NP [.Det the ] [.N mat ] ] ] ]
+
+\end{scope}
+
+\draw[->](\subtreeof{root}.140) ..
+ controls +(west:1) and +(east:1) .. (site);
+
+\end{tikzpicture}
+\end{SideBySideExample}
+\end{center}
\noindent Another example for machine translation people:
\begin{center}
@@ -288,8 +362,18 @@ There is a predefined style that draws a ``roof'' over a node, like Qtree's \ver
\end{Example}
\end{center}
+\section{Qtree compatibility}
+
+For basic trees, \tikztree{} can be used as a drop-in replacement for Qtree, but most of Qtree's advanced features are either not accessed in the same way in \tikztree{} or not implemented at all. There is a package \verb|tikz-qtree-compat| which can be loaded to improve compatibility. Supported so far are:
+\begin{itemize}
+\item Superscripts and subscripts outside of math mode, and \verb|\automath|
+\item The \verb|\0|, \verb|\1|, and \verb|\2| commands, and \verb|\qtreeprimes|
+\item The \verb|\qroof| command
+\end{itemize}
+For unsupported commands, warning messages are printed, but at least your file should compile.
+
\section*{Acknowledgements}
-This was all Dan Gildea's idea.
+This was all Dan Gildea's idea. Thanks to Alan Munn for his very helpful suggestions.
\section*{Contact}
Please send suggestions to \verb|chiang@isi.edu|.