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/tex/latex/tikz-qtree | |
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/tex/latex/tikz-qtree')
-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 |
2 files changed, 72 insertions, 22 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% 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}}} - |