summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex')
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex51
1 files changed, 39 insertions, 12 deletions
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%