diff options
author | Karl Berry <karl@freefriends.org> | 2012-04-23 23:33:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-04-23 23:33:37 +0000 |
commit | 4e726ab9f8770eb45730edb560b1276687c828ef (patch) | |
tree | e9f3d026724710e7fc1a789bddc29dd25c0f477e /Master/texmf-dist | |
parent | 1c5353c95c3d07498b0716382cd0b00489296e65 (diff) |
tikz-qtree (23apr12)
git-svn-id: svn://tug.org/texlive/trunk@26108 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/README | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf | bin | 100362 -> 106370 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex | 166 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex | 51 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex | 43 |
5 files changed, 164 insertions, 101 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/README b/Master/texmf-dist/doc/latex/tikz-qtree/README index 58ae6cd4a77..3bff4d34779 100644 --- a/Master/texmf-dist/doc/latex/tikz-qtree/README +++ b/Master/texmf-dist/doc/latex/tikz-qtree/README @@ -1,6 +1,6 @@ tikz-qtree David Chiang <chiang at isi dot edu> -Version 1.12 (October 2011) +Version 1.2 (22 Apr 2012) This package provides a macro for drawing trees with TikZ using the easy syntax of Alexis Dimitriadis' Qtree. It improves on TikZ's @@ -12,6 +12,9 @@ pst-qtree in being usable with pdfTeX and XeTeX. Please see tikztree-manual.pdf for instructions and examples. Version history: +1.2 (2012/04/20) + - level-specific styles (thanks to Andrew Stacey) + 1.12 (2011/10/10) - fixed bug that was inserting spaces diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf b/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf Binary files differindex c7060287b84..37348bbb5b0 100644 --- a/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf +++ b/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf 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 7092a4d17ba..26bc978f3ec 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 @@ -1,24 +1,14 @@ \documentclass{article} -\usepackage{xltxtra,fontspec} +\usepackage{mathspec,xltxtra} -\iffalse -\setmainfont[Mapping=tex-text]{DejaVu Serif} -\setmonofont[Scale=0.95]{DejaVu Sans Mono} -\newfontfamily\verbfont[Scale=0.8]{DejaVu Sans Mono} -\newfontfamily\ar[Script=Arabic]{DejaVu Sans} -\newfontfamily\ja{VL Gothic} -\newfontfamily\javerbfont[Scale=0.85,LetterSpace=5.0]{VL Gothic} -\fi - -\iftrue \setmainfont[Mapping=tex-text]{DejaVu Serif} \setmonofont[Scale=0.95]{DejaVu Sans Mono} \newfontfamily\verbfont[Scale=0.8]{DejaVu Sans Mono} \newfontfamily\ar[Script=Arabic]{DejaVu Sans} \newfontfamily\ja{Hiragino Maru Gothic Pro} \newfontfamily\javerbfont[Scale=0.85,LetterSpace=5.0]{Hiragino Maru Gothic Pro} -\fi +\setmathrm{DejaVu Serif} \setmathfont(Digits,Latin){DejaVu Serif} \usepackage{tikz} \usepackage{tikz-qtree} @@ -34,8 +24,8 @@ \tikzset{>=latex} \title{\tikztree: better trees with TikZ} -\author{David Chiang} -\date{Version 1.11 (Christmas 2010)} +\author{David Chiang\\\texttt{chiang@isi.edu}} +\date{Version 1.2 (22 Apr 2012)} \begin{document} @@ -81,7 +71,9 @@ below require the explicit \verb|tikzpicture| environment. \goodbreak -\paragraph{Options} Some options for standard TikZ trees work for \verb|\Tree| as +\section{Tree 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 its children @@ -97,7 +89,7 @@ no way to disambiguate the two uses of square brackets.} For example: \begin{center} \begin{SideBySideExample} \begin{tikzpicture} -\tikzset{level distance=72pt} +\tikzset{level distance=60pt} \Tree [.NP [.Adj tall ] [.N tree ] ] \end{tikzpicture} % @@ -129,34 +121,20 @@ The \verb|grow=|\textit{direction}\/ and \verb|grow'=|\textit{direction}\/ optio \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} -\tikzset{small/.style={level distance=20pt,sibling distance=0pt}} -\end{Verbatim} -Then the option \verb|small| causes the options in its definition to be used: -\begin{center} -\tikzset{small/.style={level distance=20pt,sibling distance=0pt}} -\begin{SideBySideExample} -\begin{tikzpicture}[small] -\Tree [.NP [.Adj small ] [.N tree ] ] -\end{tikzpicture} -% -\begin{tikzpicture} -\Tree [.NP [.Adj normal ] [.N tree ] ] -\end{tikzpicture} -\end{SideBySideExample} -\end{center} -The following TikZ styles are automatically applied inside trees, -providing a hook for you to change the appearance of particular kinds -of tree parts: +\section{Styles} + +\subsection{Node styles} + +The following TikZ styles are automatically applied to tree nodes, +providing a hook for you to change the appearance of nodes or particular kinds of nodes: \begin{itemize} -\item \verb|every tree node| to every (internal and leaf) node (default: \verb|anchor=base|) -\item \verb|every internal node| to every internal node -\item \verb|every leaf node| to every leaf node -\item \verb|edge from parent| to every edge (default: \verb|draw|) +\item \verb|every tree node| applies to every node (default: \verb|anchor=base|) +\item \verb|every internal node| applies to every internal node +\item \verb|every leaf node| applies to every leaf node +\item \texttt{every level $n$ node} applies to every node at level $n$, where $n=0$ is the root \end{itemize} -The options for nodes and edges are all handled by TikZ and are +The options for nodes are all handled by TikZ and are described in detail in the TikZ documentation. For example, if you have a font named \verb|\ar| and want to set all the leaf labels in this font: @@ -183,7 +161,7 @@ You can make the nodes in a sideways tree line up on their left edge using \verb [.VP [.V sat ] [.PP [.P on ] [.NP [.Det the ] [.N mat ] ] ] ] ] -\end{tikzpicture} +\end{tikzpicture} \end{SideBySideExample} \end{center} @@ -200,11 +178,13 @@ In Qtree, it was allowed to use a line break (\verb|\\|) inside a node. TikZ nod \end{SideBySideExample} \end{center} -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: +\subsection{Edge styles} + +The \verb|edge from parent| style applies to every edge (default value: \verb|draw|). By defining this style, you can change the appearance of 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}} +\tikzset{edge from parent/.append style={very thick}} \Tree [.S [.NP [.Det the ] [.N cat ] ] [.VP [.V sat ] [.PP [.P on ] @@ -212,8 +192,8 @@ You can also define a style for all the edges in a tree. For example, if you wan \end{tikzpicture} \end{SideBySideExample} \end{center} -The \verb|draw| option is necessary, as by default they will not be -drawn. As a more complex example, edges have an +Note that we must say \verb|.append style| instead of just \verb|.style|, in order to retain the \verb|draw| option without which the edge will be invisible. +As a more complex example, edges have an \verb|edge from parent path| option which lets you change the shape of the edge. Its value is a TikZ path expressed in terms of \verb|\tikzparentnode|, the parent node, and \verb|\tikzchildnode|, @@ -234,7 +214,43 @@ the child node. \end{SideBySideExample} \end{center} -\clearpage +\subsection{Node placement styles} + +The following styles aren't applied to nodes, but affect the placement of nodes. By defining these styles, you can change the options \verb|level distance| or \verb|sibling distance| for different parts of the tree.\footnote{Thanks to Andrew Stacey for helping with the implementation.} +\begin{itemize} +\item \texttt{level $n$} applies to the placement of level $n$ (relative to level $n-1$) +\item \texttt{level $n$+} applies to level $n$ and below +\item \verb|interior| applies to the placement of internal nodes (except the root) +\item \verb|frontier| applies to the placement of leaves +\end{itemize} + +\begin{center} +\begin{SideBySideExample} +\begin{tikzpicture} +\tikzset{level 1/.style={level distance=36pt}} +\tikzset{level 2/.style={level distance=32pt}} +\tikzset{level 3+/.style={level distance=28pt}} +\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 this context, you can also set the option \verb|distance from root|, which positions a level relative to the root instead of the parent level. This is particularly useful for aligning all the leaf nodes: +\begin{center} +\begin{SideBySideExample} +\begin{tikzpicture} +\tikzset{frontier/.style={distance from root=150pt}} +\Tree [.S [.NP [.Det the ] [.N cat ] ] + [.VP [.V sat ] + [.PP [.P on ] + [.NP [.Det the ] [.N mat ] ] ] ] ] +\end{tikzpicture} +\end{SideBySideExample} +\end{center} +Unfortunately, the depth of the deepest leaf node is a global property of the tree and not easy to know during tree rendering, so you do have to specify the absolute depth of the leaf nodes. It will typically be an integer multiple of \verb|level distance|. \section{Embedding TikZ nodes} @@ -262,7 +278,7 @@ also optional, can be used for drawing lines/arrows to/from the node. [.\node[draw]{NP}; [.NP [.Det a ] [.N book ] ] [.PP [.P about ] [.NP \node(t){$t$}; ] ] ] ] ] ] ] ] -\draw[semithick,->] (t)..controls +(south west:5) and +(south:5) .. (wh); +\draw[semithick,->] (t)..controls +(south west:5) and +(south:5)..(wh); \end{tikzpicture} \end{Example} \end{center} @@ -277,12 +293,9 @@ You can also refer to the whole subtree rooted at the node named \textit{name}\/ \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); - +\draw[->](\subtreeof{root}.140).. + controls +(west:1) and +(east:1)..(site); \end{tikzpicture} \end{SideBySideExample} \end{center} @@ -292,14 +305,16 @@ You can also refer to the whole subtree rooted at the node named \textit{name}\/ \fvset{formatcom=\javerbfont} \begin{SideBySideExample} \begin{tikzpicture} +\begin{scope}[frontier/.style={distance from root=150pt}] \Tree [.S [.NP [.Det \node(e1){the}; ] [.N \node(e2){cat}; ] ] [.VP [.V \node(e3){sat}; ] [.PP [.P \node(e4){on}; ] [.NP [.Det \node(e5){the}; ] [.N \node(e6){mat}; ] ] ] ] ] - -\begin{scope}[yshift=-5in,grow'=up] +\end{scope} +\begin{scope}[xshift=9pt,yshift=-5in,grow'=up, + frontier/.style={distance from root=150pt}] \tikzset{every leaf node/.style={font=\ja}} \Tree [.S [.NP \node(j1){猫が}; ] [.VP [.PP [.NP [.NP \node(j2){マット}; ] @@ -308,17 +323,15 @@ You can also refer to the whole subtree rooted at the node named \textit{name}\/ [.P \node(j5){に}; ] ] [.V \node(j6){土}; ] ] ] \end{scope} - \begin{scope}[dashed] \draw (e1)--(j1); \draw (e2)--(j1); -\draw (e3)..controls +(south:5) and +(north:4)..(j6); +\draw (e3)--(j6); \draw (e4)--(j4); \draw (e4)--(j5); \draw (e5)--(j2); \draw (e6)--(j2); \end{scope} - \end{tikzpicture} \end{SideBySideExample} \end{center} @@ -336,7 +349,21 @@ more logical to put it before.} \end{quote} Again, don't forget the semicolon. The \verb|[|\textit{options}\verb|]|, which are optional, let you change -the appearance of the edge. You can also add an edge label: +the appearance of the edge, as described above. + +There is a predefined edge style \verb|roof| that draws a triangle-shaped edge over a node, like Qtree's \verb|\qroof|: +\begin{center} +\begin{Example} +\begin{tikzpicture}[level distance=40pt] +\Tree [.S [.NP [.N this ] ] + [.VP [.V is ] + [.NP \edge[roof]; {a noun phrase the complexity of which + is too great for me to parse} ] ] ] +\end{tikzpicture} +\end{Example} +\end{center} + +You can also add a label to the edge, using the following syntax: \begin{quote} \verb|\edge [|\textit{options}\verb|] node [|\textit{options}\verb|] {|\textit{label}\verb|};| \end{quote} @@ -346,7 +373,6 @@ places the label to the side of the edge. \begin{SideBySideExample}[xrightmargin=1.25in] \newcommand{\initial}[1]{\ensuremath{\alpha_{\textrm{\scriptsize #1}}}} \newcommand{\auxiliary}[1]{\ensuremath{\beta_{\textrm{\scriptsize #1}}}} - \begin{tikzpicture}[level distance=36pt,sibling distance=12pt] \Tree [.\initial{sat} \edge node[auto=right]{1}; \initial{cat} @@ -360,19 +386,6 @@ The fact that \verb|auto=left| draws a label on the right and \verb|auto=right| draws a label on the left makes sense if you think about the tree growing from the root to the leaves. -There is a predefined style that draws a ``roof'' over a node, like Qtree's \verb|\qroof|: -\begin{center} -\begin{Example} -\begin{tikzpicture}[level distance=36pt] -\Tree [.S [.NP [.N this ] ] - [.VP [.V is ] - [.NP \edge[roof]; {a noun phrase - the complexity of which - is too great for me to parse} ] ] ] -\end{tikzpicture} -\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: @@ -381,12 +394,9 @@ For basic trees, \tikztree{} can be used as a drop-in replacement for Qtree, but \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. +For unsupported commands, warning messages are printed, but your file should compile. \section*{Acknowledgements} -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|. +This was all Dan Gildea's idea. Thanks to Alan Munn for his very helpful suggestions, and to Andrew Stacey for modifications. \end{document} diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex index 8173ed13cb8..7f67c8ff528 100644 --- a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex @@ -1,5 +1,5 @@ % pgftree.tex -% Version 1.1, 25 Dec 2009 +% Version 1.2, 20 Apr 2012 % Copyright 2009 by David Chiang @@ -17,6 +17,9 @@ % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +% New in version 1.2: +% - level-specific styles (thanks to Andrew Stacey) + % New in version 1.1: % - major restructuring to not do arbitrary nesting of subpicture environments % - sideways trees @@ -28,6 +31,10 @@ \newdimen\levelsep \levelsep=30pt \newdimen\subtreesep \subtreesep=2pt +\newdimen\smuggle@levelsep +\newdimen\smuggle@subtreesep +\newdimen\this@levelsep +\newdimen\this@subtreesep \def\leveldirection{down} \def\siblingdirection{right} @@ -82,11 +89,15 @@ \newdimen\pgftree@savechildy \newcount\pgftree@childi \newcount\pgftree@savechildi +\newcount\pgftree@level +\newdimen\pgftree@depth %%% \pgftree{subtree} \def\pgftree#1{% \def\nodename{r}% +\pgftree@level=0\relax +\pgftree@depth=0pt\relax #1% \pgfplacesubpicture } @@ -95,9 +106,10 @@ % The first argument draws the root node using PGF/TikZ commands. % The node must be named \nodename. -% The second argument is an even-length sequence of tokens. -% Token 2n-1 in the sequence draws the nth edge. It should draw an edge from \parentnodename to \nodename. -% Token 2n in the sequence draws the nth subtree. Its root must be named \nodename. +% The second argument is a sequence of 3n tokens. +% Token 3n-2 draws the nth edge. It should draw an edge from \parentnodename to \nodename. +% Token 3n-1 is a hook that can change \levelsep or \subtreesep for child n only. +% Token 3n draws the nth subtree. Its root must be named \nodename. \pgfnewsubpicture{children} \newdimen\pgftree@lastchildx @@ -118,9 +130,7 @@ #1% \ifnum\pgftree@childi>0% % Place children -% move down \levelsep -{\pgftransformshift{\pgftree@levelshift}% -% center so that parent is midway between origins of first and last children +{% center so that parent is midway between origins of first and last children \pgftransformshift{\pgfpointscale{-0.5}{\pgfqpoint{\the\pgftree@childx}{\the\pgftree@childy}}}% \pgfplacesubpicture}% % Draw the edges @@ -145,20 +155,37 @@ }% {\@process@children}% } -\def\@process@children#1#2{% #1 is the edge, #2 is the child +\def\@process@children#1#2#3{% +% #1 is the edge, #2 is the hook, #3 is the child +{% call hook to get \levelsep and \subtreesep +% and put them in \this@levelsep and \this@subtreesep +% to hide them from descendants +#2% +\global\smuggle@levelsep\levelsep +\global\smuggle@subtreesep\subtreesep}% +\this@levelsep\smuggle@levelsep +\this@subtreesep\smuggle@subtreesep % Build the current child {\edef\nodename{\parentnodename-\the\pgftree@childi}% -#2}% +\advance\pgftree@level by 1\relax +\advance\pgftree@depth by \this@levelsep +#3}% \begin{pgfsubpicture}% % Place current child +{% +% The \levelsep and \subtreesep set in #2 apply only here +\levelsep\this@levelsep +\subtreesep\this@subtreesep \ifnum\pgftree@childi>0% the first child is always at 0 \pgftree@presiblingshift \global\advance\pgftree@childx\pgf@x \global\advance\pgftree@childy\pgf@y \fi -{\pgftransformshift{\pgfqpoint{\the\pgftree@childx}{\the\pgftree@childy}}% -\pgfplacesubpicture}% +\pgftransformshift{\pgftree@levelshift}% +\pgftransformshift{\pgfqpoint{\the\pgftree@childx}{\the\pgftree@childy}}% +\pgfplacesubpicture \global\pgftree@lastchildx\pgftree@childx \global\pgftree@lastchildy\pgftree@childy \pgftree@postsiblingshift \global\advance\pgftree@childx\pgf@x \global\advance\pgftree@childy\pgf@y +}% % Save the augmented row of children back into "children" \end{pgfsubpicture} \ifnum\pgftree@childi>0% @@ -175,7 +202,7 @@ {}% {\@process@edges}% } -\def\@process@edges#1#2{% +\def\@process@edges#1#2#3{% \edef\nodename{\parentnodename-\the\pgftree@childi}% #1% \advance\pgftree@childi by 1% diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex index 17c8f3cb135..c28db5bae6a 100644 --- a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex +++ b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex @@ -1,5 +1,5 @@ % tikz-qtree.tex -% Version 1.11, 25 Dec 2010 +% Version 1.2, 20 Apr 2012 % Copyright (C) 2002, 2009 by David Chiang @@ -17,11 +17,13 @@ % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +% New in version 1.2: +% - level-specific styles (thanks to Andrew Stacey) + % New in version 1.11: % - make options compatible with standard tikz trees % New in version 1.1: - % - sideways trees %% These macros facilitate building up an object recursively before @@ -75,9 +77,13 @@ } \def\@@@@@@subtree{% \@ifequal{\the\root@node}{\pgfutil@empty}% -\edef\act{\noexpand\@result={\noexpand\pgfsubtree{\noexpand\path coordinate (\noexpand\nodename);}{\the\child@list}}}% +\edef\act{\noexpand\@result={% +\noexpand\subtree@hook +\noexpand\pgfsubtree{\noexpand\path coordinate (\noexpand\nodename);}{\the\child@list}}}% \else -\edef\act{\noexpand\@result={\noexpand\pgfsubtree{\the\root@node}{\the\child@list}}}% +\edef\act{\noexpand\@result={% +\noexpand\subtree@hook +\noexpand\pgfsubtree{\the\root@node}{\the\child@list}}}% \fi \act \@return} @@ -104,8 +110,12 @@ \expandafter\child@list\expandafter{\the\child@list{\edge@adapter{}}}% \fi \scanned@edgefalse -\pgfutil@ifnextchar[{\@call\@subtree\@@@children}% subtree -{\@call\@leaf\@@@children}% leaf +\pgfutil@ifnextchar[{% subtree +\expandafter\child@list\expandafter{\the\child@list{\level@hook\interior@hook}}% +\@call\@subtree\@@@children}% +{% leaf +\expandafter\child@list\expandafter{\the\child@list{\level@hook\frontier@hook}}% +\@call\@leaf\@@@children}% }}} \def\@@@children{% % wrap child inside curly braces @@ -114,10 +124,12 @@ \@@children } -\def\@interior.{\@result{\node[alias=\nodename][every tree node,every internal node]}\@label} +\def\@interior.{\@result{\node[alias=\nodename][every tree node,every internal node,every level \the\pgftree@level\space node/.try]}\@label} \def\@leaf{\@call\@label\@@leaf} -\def\@@leaf{\edef\act{\noexpand\@result{\noexpand\pgfsubtree{\noexpand\node[alias=\noexpand\nodename][every tree node,every leaf node]\the\@result}{}}}\act\@return} +\def\@@leaf{\edef\act{\noexpand\@result{% +\noexpand\subtree@hook +\noexpand\pgfsubtree{\noexpand\node[alias=\noexpand\nodename][every tree node,every leaf node,every level \noexpand\the\pgftree@level\space node/.try]\the\@result}{}}}\act\@return} \def\@edge\edge #1;{% \@result{\edge@adapter{#1}}% @@ -128,6 +140,17 @@ \path edge from parent #1;% } +\def\level@hook{% +{\advance\pgftree@level by 1\relax +\xdef\@act{\noexpand\tikzset{level \the\pgftree@level/.try}}}\@act} +\def\subtree@hook{% +%\edef\act{\noexpand\tikzset{every tree node/.append code={\noexpand\tikzset{every level \the\pgftree@level+ node/.try}}}}\act +{\advance\pgftree@level by 1\relax +\xdef\@act{\noexpand\tikzset{level \the\pgftree@level+/.try}}}\@act +} +\def\interior@hook{\tikzset{interior/.try}} +\def\frontier@hook{\tikzset{frontier/.try}} + % a label is either text or PGF/TikZ code starting with \node \def\@label{\pgfutil@ifnextchar\node{\@litlabel}{\@@label}} \def\@@label#1 {% @@ -153,6 +176,7 @@ %%% Options \pgfkeysgetvalue{/tikz/level distance/.@cmd}{\orig@leveldistance} \tikzoption{level distance}{\pgfmathsetlength\levelsep{#1}\orig@leveldistance#1\pgfeov} +\tikzoption{distance from root}{\pgfmathsetlength\levelsep{#1}\advance\levelsep by -\pgftree@depth} \pgfkeysgetvalue{/tikz/sibling distance/.@cmd}{\orig@siblingdistance} \tikzoption{sibling distance}{\pgfmathsetlength\subtreesep{#1}\orig@siblingdistance#1\pgfeov} % different semantics @@ -171,11 +195,10 @@ \def\growprime@right{\def\leveldirection{right}\def\siblingdirection{down}} % defaults appropriate for linguistic trees +\def\tikz@edge@to@parent@path{\tree@edge{\tikzparentnode}{\tikzchildnode}} \tikzset{every tree node/.style={anchor=base}} \tikzset{every leaf node/.style={}} \tikzset{every internal node/.style={}} -\def\tikz@edge@to@parent@path{\tree@edge{\tikzparentnode}{\tikzchildnode}} % predefined roof style \tikzset{roof/.style={edge from parent path=\roof@edge{\tikzparentnode}{\tikzchildnode}}} - |