summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikz-qtree
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-qtree')
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex116
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex167
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree-compat.sty72
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex53
4 files changed, 320 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
index 928ae336e95..4acd7d57b28 100644
--- a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
+++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
@@ -1,5 +1,5 @@
% pgfsubpic.tex
-% Version 1, 22 Dec 2009
+% Version 1.1, 25 Dec 2009
% Copyright 2009 by David Chiang
@@ -17,6 +17,14 @@
% 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.1:
+% - the ability to save a subpicture in local variables
+% - nodes in subpictures are tracked if the subpicture is placed with arbitrary transforms
+% - new \pgffitsubpicture macro to transform a subpicture (preserving aspect) to fit in a desired box
+
+% To do:
+% - speed up interpictureshift hook by promoting subsubpictures
+
\newdimen\pgf@subpicminx
\newdimen\pgf@subpicminy
\newdimen\pgf@subpicmaxx
@@ -28,14 +36,15 @@
\def\southwest{\pgfqpoint{\pgf@subpicminx}{\pgf@subpicminy}}%
\def\northeast{\pgfqpoint{\pgf@subpicmaxx}{\pgf@subpicmaxy}}%
}
-\expandafter\def\csname pgf@sh@nt@current subpicture\endcsname{{1}{0}{0}{1}{0pt}{0pt}}
+\expandafter\def\csname pgf@sh@nt@current subpicture\endcsname{{\pgf@pt@aa}{\pgf@pt@ab}{\pgf@pt@ba}{\pgf@pt@bb}{\the\pgf@pt@x}{\the\pgf@pt@y}} % the transformation at invocation time
\expandafter\def\csname pgf@sh@pi@current subpicture\endcsname{\pgfpictureid}
% Create a pgfpicture inside an hbox for delayed placement
\def\pgfsubpicture{%
-\global\setbox\pgf@hbox=\hbox\bgroup
-\pgfinterruptpicture%
-\pgfpicture%
+\expandafter\global\expandafter\setbox\pgf@hbox=\hbox\bgroup
+\pgfinterruptpicture
+\pgfpicture
+\relax % not sure why. otherwise a curly brace immediately after causes an error
}
\def\endpgfsubpicture{
@@ -50,19 +59,51 @@
\egroup
}
+% Allocate registers for saving a subpicture. #1 is text, not a control sequence.
+\def\pgfnewsubpicture#1{%
+\expandafter\newbox\csname pgf@subpic@hbox@#1\endcsname
+\expandafter\newdimen\csname pgf@subpic@minx@#1\endcsname
+\expandafter\newdimen\csname pgf@subpic@miny@#1\endcsname
+\expandafter\newdimen\csname pgf@subpic@maxx@#1\endcsname
+\expandafter\newdimen\csname pgf@subpic@maxy@#1\endcsname
+}
+
+% saved subpictures are local to the current group
+\def\pgfsavesubpicture#1{%
+\expandafter\setbox\csname pgf@subpic@hbox@#1\endcsname\copy\pgf@hbox
+\csname pgf@subpic@minx@#1\endcsname\pgf@subpicminx
+\csname pgf@subpic@miny@#1\endcsname\pgf@subpicminy
+\csname pgf@subpic@maxx@#1\endcsname\pgf@subpicmaxx
+\csname pgf@subpic@maxy@#1\endcsname\pgf@subpicmaxy
+\expandafter\edef\csname pgf@subpic@id@#1\endcsname{\subpictureid}
+}
+
+\def\pgfrestoresubpicture#1{%
+\edef\act{\global\noexpand\setbox\pgf@hbox\noexpand\copy\csname pgf@subpic@hbox@#1\endcsname}\act
+\expandafter\global\expandafter\pgf@subpicminx\csname pgf@subpic@minx@#1\endcsname
+\expandafter\global\expandafter\pgf@subpicminy\csname pgf@subpic@miny@#1\endcsname
+\expandafter\global\expandafter\pgf@subpicmaxx\csname pgf@subpic@maxx@#1\endcsname
+\expandafter\global\expandafter\pgf@subpicmaxy\csname pgf@subpic@maxy@#1\endcsname
+\xdef\subpictureid{\csname pgf@subpic@id@#1\endcsname}
+}
+
% Place a previously-created subpicture, lining up its origin with the current origin
\def\pgfplacesubpicture{
\pgfscope
% expand current bounding box to accommodate subpicture
-\pgfpathmoveto{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}%
-\pgfpathlineto{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
+\pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
\pgfusepath{use as bounding box}%
-% save relative position of subpicture inside containing picture
-\pgfpointorigin
-\pgf@pos@transform{\pgf@x}{\pgf@y}%
-\expandafter\xdef\csname pgf@subpic@\subpictureid @x\endcsname{\the\pgf@x}%
-\expandafter\xdef\csname pgf@subpic@\subpictureid @y\endcsname{\the\pgf@y}%
-\expandafter\xdef\csname pgf@subpic@\subpictureid @p\endcsname{\pgfpictureid}%
+%
+% make the subpicture a node in the containing picture
+\expandafter\gdef\csname pgf@sh@ns@\subpictureid\endcsname{rectangle}
+\expandafter\xdef\csname pgf@sh@np@\subpictureid\endcsname{%
+ \noexpand\def\noexpand\southwest{\noexpand\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}%
+ \noexpand\def\noexpand\northeast{\noexpand\pgfqpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
+}%
+\pgfgettransform\pgf@temp
+\expandafter\xdef\csname pgf@sh@nt@\subpictureid\endcsname{\pgf@temp}%
+\expandafter\xdef\csname pgf@sh@pi@\subpictureid\endcsname{\pgfpictureid}%
+%
% align origin of subpicture with origin
\pgftransformshift{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}%
\pgfqboxsynced{\pgf@hbox}%
@@ -73,6 +114,13 @@
% This is called whenever we look up an anchor of a node.
% This hook recursively checks to see if the node's picture
% is a subpicture of another, and if so, adjusts its position accordingly.
+
+% This is slow. It makes drawing trees O(n^2) in the depth of the tree.
+% The alternative is to store, for each picture, a list of the nodes
+% inside it. But this way doesn't require us to hijack \pgfnode, and
+% is robust to re-placement of a subpicture. A compromise would be
+% to store, for each picture, a list of the *subpictures* inside it.
+
\let\orig@pgf@shape@interpictureshift\pgf@shape@interpictureshift
\def\unwind@subpic#1{%
% is #1 the current picture?
@@ -81,14 +129,18 @@
% yes, we're done
\else
% does #1 have a parent picture?
-\expandafter\ifx\csname pgf@subpic@#1@p\endcsname\relax
+\expandafter\ifx\csname pgf@sh@pi@#1\endcsname\relax
% no, the original node was not inside the current picture
\fallback
\else
-% yes, apply shift and move up to parent picture
-\global\advance\pgf@x by \csname pgf@subpic@#1@x\endcsname
-\global\advance\pgf@y by \csname pgf@subpic@#1@y\endcsname
-\unwind@subpic{\csname pgf@subpic@#1@p\endcsname}%
+% yes, apply transform and move up to parent picture
+{%
+ \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
+ \pgf@pos@transform{\pgf@x}{\pgf@y}%
+ \global\pgf@x=\pgf@x
+ \global\pgf@y=\pgf@y
+}%
+\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}%
\fi
\fi
}
@@ -97,6 +149,33 @@
\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}%
}
+% \pgffitsubpicture{sw}{ne}
+% Make the subpicture fit in the rectangle from sw to ne, preserving its aspect ratio.
+\def\pgffitsubpicture#1#2{%
+% current size
+\pgfpointdiff{\pgfpointanchor{current subpicture}{south west}}{\pgfpointanchor{current subpicture}{north east}}%
+\pgf@xa=\pgf@x \pgf@ya=\pgf@y
+% desired size
+\pgf@process{\pgfpointdiff{#1}{#2}}%
+\pgf@xb=\pgf@x \pgf@yb=\pgf@y
+\pgfmathparse{min(\pgf@xb/\pgf@xa,\pgf@yb/\pgf@ya)}%
+\pgfmathparse{min(1,\pgfmathresult)}%
+\pgftransformscale{\pgfmathresult}%
+%
+% current position
+\pgfpointanchor{current subpicture}{center}%
+\pgf@xa=\pgf@x \pgf@ya=\pgf@y
+% desired position
+% we scaled transform, so apply reverse scaling to argument
+\pgfmathparse{1/\pgfmathresult}%
+\pgf@process{\pgfpointscale{\pgfmathresult}{\pgfpointlineattime{0.5}{#1}{#2}}}%
+\pgf@xb=\pgf@x \pgf@yb=\pgf@y
+\pgfpointdiff{\pgfpoint{\pgf@xa}{\pgf@ya}}{\pgfpoint{\pgf@xb}{\pgf@yb}}%
+\pgftransformshift{\pgfpoint{\pgf@x}{\pgf@y}}%
+}
+
+% utility functions -- not currently used
+
\def\pgfnodedelete#1{%
\expandafter\global\expandafter\let\csname pgf@sh@ns@#1\endcsname\relax
\expandafter\global\expandafter\let\csname pgf@sh@np@#1\endcsname\relax
@@ -108,3 +187,4 @@
\def\pgfnodeifexists#1#2#3{%
\expandafter\ifx\csname pgf@sh@ns@#1\endcsname\relax#3\else#2\fi
}
+
diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex
index 4cdaad16433..a3fca8b0b48 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, 22 Dec 2009
+% Version 1.1, 25 Dec 2009
% Copyright 2009 by David Chiang
@@ -17,30 +17,81 @@
% with this program; if not, write to the Free Software Foundation, Inc.,
% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-% to do:
-% if \nodename does not exist as desired, wrap inside a rectangle node
-% don't use pgfsubpic internals, use anchors instead
+% New in version 1.1:
+% - major restructuring to not do arbitrary nesting of subpicture environments
+% - sideways trees
+
+% To do:
+% - trees with all leaves at same level
+% - if \nodename does not exist as desired, wrap inside a rectangle node
+% - don't use pgfsubpic internals
\newdimen\levelsep \levelsep=30pt
\newdimen\subtreesep \subtreesep=2pt
-\newif\ifrighttoleft
-\newif\ifupsidedown
+
+\def\leveldirection{down}
+\def\siblingdirection{right}
+
+% definitions of growing directions
+\def\pgftree@levelshift{\csname pgftree@levelshift@\leveldirection\endcsname}
+\def\pgftree@parentanchor{\csname pgftree@parentanchor@\leveldirection\endcsname}
+\def\pgftree@childanchor{\csname pgftree@childanchor@\leveldirection\endcsname}
+% these assume that the current subpicture is the child
+\def\pgftree@presiblingshift{\csname pgftree@presiblingshift@\siblingdirection\endcsname}
+\def\pgftree@postsiblingshift{\csname pgftree@postsiblingshift@\siblingdirection\endcsname}
+
+\def\pgftree@levelshift@down{\pgfpoint{0}{-\levelsep}}
+\def\pgftree@parentanchor@down{south}
+\def\pgftree@childanchor@down{north}
+
+\def\pgftree@levelshift@up{\pgfpoint{0}{\levelsep}}
+\def\pgftree@parentanchor@up{north}
+\def\pgftree@childanchor@up{south}
+
+\def\pgftree@levelshift@right{\pgfpoint{\levelsep}{0}}
+\def\pgftree@parentanchor@right{east}
+\def\pgftree@childanchor@right{west}
+
+\def\pgftree@levelshift@left{\pgfpoint{-\levelsep}{0}}
+\def\pgftree@parentanchor@left{west}
+\def\pgftree@childanchor@left{east}
+
+\def\pgftree@presiblingshift@right{\pgf@process{\pgf@x-\pgf@subpicminx \advance\pgf@x\subtreesep \pgf@y 0pt}}
+\def\pgftree@postsiblingshift@right{\pgf@process{\pgf@x\pgf@subpicmaxx \pgf@y 0pt}}
+
+\def\pgftree@presiblingshift@left{\pgf@process{\pgf@x-\pgf@subpicmaxx \advance\pgf@x-\subtreesep \pgf@y 0pt}}
+\def\pgftree@postsiblingshift@left{\pgf@process{\pgf@x\pgf@subpicminx \pgf@y 0pt}}
+
+\def\pgftree@presiblingshift@up{\pgf@process{\pgf@x 0pt \pgf@y-\pgf@subpicminy \advance\pgf@y\subtreesep}}
+\def\pgftree@postsiblingshift@up{\pgf@process{\pgf@x 0pt \pgf@y\pgf@subpicmaxy}}
+
+\def\pgftree@presiblingshift@down{\pgf@process{\pgf@x 0pt \pgf@y-\pgf@subpicmaxy \advance\pgf@y-\subtreesep}}
+\def\pgftree@postsiblingshift@down{\pgf@process{\pgf@x 0pt \pgf@y\pgf@subpicminy}}
+
+% for convenience if you are using \pgftree directly
\def\drawnode#1{\pgfnode{rectangle}{base}{#1}{\nodename}{\pgfusepath{discard}}}
\def\drawedge{%
-\pgfpathmoveto{\pgfpointanchor{\parentnodename}{\ifupsidedown north\else south\fi}}%
-\pgfpathlineto{\pgfpointanchor{\nodename}{\ifupsidedown south\else north\fi}}%
+\pgfpathmoveto{\pgfpointanchor{\parentnodename}{\pgftree@parentanchor}}%
+\pgfpathlineto{\pgfpointanchor{\nodename}{\pgftree@childanchor}}%
\pgfusepath{stroke}}
% local variables that we need to assign to inside a \pgfforeach
\newdimen\pgftree@childx
\newdimen\pgftree@savechildx
+\newdimen\pgftree@childy
+\newdimen\pgftree@savechildy
\newcount\pgftree@childi
\newcount\pgftree@savechildi
-\def\nodename{r}
+%%% \pgftree{subtree}
-%%% \pgftree{root}{subtrees}
+\def\pgftree#1{%
+\def\nodename{r}%
+#1
+\pgfplacesubpicture
+}
+%%% \pgfsubtree{root}{subtrees}
% The first argument draws the root node using PGF/TikZ commands.
% The node must be named \nodename.
@@ -48,60 +99,79 @@
% 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.
-\def\pgftree#1#2{%
-\pgfscope
-% create root node
-#1
+\pgfnewsubpicture{children}
+\pgfnewsubpicture{child}
+\newdimen\pgftree@lastchildx
+\newdimen\pgftree@lastchildy
+
+\def\pgfsubtree#1#2{%
\let\parentnodename\nodename
-\ifupsidedown
-\pgftransformshift{\pgfpoint{0}{\levelsep}}%
-\else
-\pgftransformshift{\pgfpoint{0}{-\levelsep}}%
-\fi
\pgftree@savechildx=\pgftree@childx
+\pgftree@savechildy=\pgftree@childy
\pgftree@savechildi=\pgftree@childi
-\pgfsubpicture
-\pgftree@childx=0pt%
+% Build subpicture with all the children and their subtrees. Save it in "children"
+{\pgftree@childx=0pt%
+\pgftree@childy=0pt%
\pgftree@childi=0%
-{\process@children #2}%
-\endpgfsubpicture
+\process@children #2}%
\ifnum\pgftree@childi>0%
-% Center children so that parent is midway between origins of first and last children
-\pgftransformshift{\pgfpointscale{-0.5}{\pgfpoint{\the\pgftree@childx}{0}}}%
-\pgfplacesubpicture
+\begin{pgfsubpicture}%
+% Create root node
+#1
+% Place children
+% move down \levelsep
+{\pgftransformshift{\pgftree@levelshift}%
+% center so that parent is midway between origins of first and last children
+\pgftransformshift{\pgfpointscale{-0.5}{\pgfpoint{\the\pgftree@childx}{\the\pgftree@childy}}}%
+\pgfplacesubpicture}
% Draw the edges
-\pgftree@childi=0%
-{\process@edges #2}%
+{\pgftree@childi=0%
+\process@edges #2}%
+\end{pgfsubpicture}%
+\else % leaf node
+\begin{pgfsubpicture}%
+#1
+\end{pgfsubpicture}%
\fi
\global\pgftree@childi=\pgftree@savechildi
\global\pgftree@childx=\pgftree@savechildx
-\endpgfscope
+\global\pgftree@childy=\pgftree@savechildy
}
\def\process@children{%
\pgfutil@ifnextchar\egroup
-{% Step back to origin of last child
-\advance\pgftree@childx by \ifrighttoleft-\pgf@subpicminx\else-\pgf@subpicmaxx\fi
-\global\pgftree@childx=\pgftree@childx
-\global\pgftree@childi=\pgftree@childi
+{% No more children, step back to origin of last child
+\global\pgftree@childx\pgftree@lastchildx
+\global\pgftree@childy\pgftree@lastchildy
+\global\pgftree@childi\pgftree@childi
+\pgfrestoresubpicture{children}% pass children back to caller
}%
{\@process@children}%
}
-\def\@process@children#1#2{%
-\edef\nodename{\parentnodename-\the\pgftree@childi}%
-\def\child{#2}%
-\pgfsubpicture
-#2%
-\endpgfsubpicture
+\def\@process@children#1#2{% #1 is the edge, #2 is the child
+% Build the current child and save it as "child"
+{\edef\nodename{\parentnodename-\the\pgftree@childi}%
+#2}%
+\pgfsavesubpicture{child}%
+\begin{pgfsubpicture}
+% Place previous children (if any)
\ifnum\pgftree@childi>0%
-\advance\pgftree@childx by \ifrighttoleft-\pgf@subpicmaxx\else-\pgf@subpicminx\fi
-\advance\pgftree@childx by \ifrighttoleft-\subtreesep\else\subtreesep\fi
-\fi
-\pgfscope
-\pgftransformshift{\pgfpoint{\the\pgftree@childx}{0}}%
+\pgfrestoresubpicture{children}%
\pgfplacesubpicture
-\endpgfscope
-\advance\pgftree@childx by \ifrighttoleft\pgf@subpicminx\else\pgf@subpicmaxx\fi
+\fi
+% Place current child
+\pgfrestoresubpicture{child}%
+\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
+\global\pgftree@lastchildx\pgftree@childx
+\global\pgftree@lastchildy\pgftree@childy
+{\pgftransformshift{\pgfpoint{\the\pgftree@childx}{\the\pgftree@childy}}%
+\pgfplacesubpicture}%
+\pgftree@postsiblingshift \global\advance\pgftree@childx\pgf@x \global\advance\pgftree@childy\pgf@y
+\end{pgfsubpicture}%
+% Save the augmented row of children back into "children"
+\pgfsavesubpicture{children}%
\advance\pgftree@childi by 1%
\process@children
}
@@ -117,3 +187,8 @@
\advance\pgftree@childi by 1%
\process@edges
}
+
+\def\subtreeof#1{%
+% the subpicture which contains a node also contains exactly its subtree
+\csname pgf@sh@pi@#1\endcsname
+}
diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree-compat.sty b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree-compat.sty
new file mode 100644
index 00000000000..f60ae32838b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree-compat.sty
@@ -0,0 +1,72 @@
+% tikz-qtree-compat.tex
+% Version 1.1, 25 Dec 2009
+
+\RequirePackage{tikz-qtree}
+
+\let\orig@Tree\Tree
+\def\Tree{\automath \qtreeprimes@internal \orig@Tree}
+
+\def\qsetw#1{\message{\noexpand\qsetw is not supported, sorry!}}
+\def\faketreewidth#1{\message{\noexpand\faketreewidth is not supported, sorry!}}
+\def\qbalance{\message{\noexpand\qbalance is not supported, sorry!}}
+\def\qframesubtree{\message{\noexpand\qframesubtree is not supported, sorry!}}
+
+% Implement \qroof as a fancy leaf node
+\newtoks\@qrooflabel
+
+\def\qroof#1.{%
+\begin{tikzpicture}[baseline]
+{\pgftransformshift{\pgftree@levelshift}%
+\node(qroofbot){#1};}
+\@qroof
+}
+\def\@qroof{\@ifnextchar\egroup{%
+% since we are putting the qroof inside a node, we already have an inner sep
+% so for the purposes of defining our bounding box, we must eliminate inner sep
+\begin{pgfsubpicture}
+\node [inner sep=0pt] {\the\@qrooflabel};%
+\end{pgfsubpicture}
+\pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
+\pgfusepath{use as bounding box}%
+\node (qrooftop) {\the\@qrooflabel};
+\draw \roof@edge{qrooftop}{qroofbot};%
+\end{tikzpicture}}
+{\@@qroof}}
+\def\@@qroof#1{\expandafter\@qrooflabel\expandafter{\the\@qrooflabel #1}\@qroof}
+
+%%% This is lifted straight from qtree.sty
+
+% and another odd convenience:
+%
+% Make _, ^ go into math mode automatically in the scope of \automath
+%
+{ % Temporarily change catcodes
+\catcode`\_=\active
+\catcode`\^=\active
+
+ \global\def\automath{%
+ \catcode`\_=\active
+ \catcode`\^=\active
+ \def_##1{\@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}%
+ \def^##1{\@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}}
+}
+\def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}}
+% Restore default catcodes for ^, _
+\def\noautomath{\catcode`\_=8 \catcode`\^=7 }
+
+
+% Let \0, \1, \2 produce ^0, $'$, $''$
+% The \rlap results in better centering of the label (ignoring the
+% superscript)
+\def\qtreeprimes@internal{%
+ \def\0{\ifmmode ^0\else \rlap{$^0$}\fi}%
+ \def\1{\ifmmode '\else \rlap{$'$}\fi}%
+ \def\2{\ifmmode ''\else \rlap{$''$}\fi}%
+}
+
+% Same commands, but without the \rlap feature
+\def\qtreeprimes{%
+ \def\0{\ensuremath{^0}}%
+ \def\1{\ensuremath{'}}%
+ \def\2{\ensuremath{''}}}
+
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 6114da8468b..09282e63e09 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 @@
-% tikztree.tex
-% Version 1, 22 Dec 2009
+% tikz-qtree.tex
+% Version 1.1, 25 Dec 2009
% Copyright (C) 2002, 2009 by David Chiang
@@ -17,6 +17,10 @@
% 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.1:
+
+% - sideways trees
+
%% These macros facilitate building up an object recursively before
%% putting it into the input stream.
@@ -32,7 +36,11 @@
\def\Tree{\@call\@subtree\@Tree}
\def\@Tree{%
%\showthe\@result %debug
-\ifpgfpicture\the\@result\else\tikzpicture\the\@result\endtikzpicture\fi % is there a test for tikzpicture?
+\ifpgfpicture % is there a test for tikzpicture?
+\pgftree{\the\@result}%
+\else
+\tikzpicture[baseline]\pgftree{\the\@result}\endtikzpicture
+\fi
}
%% scan a subtree
@@ -64,9 +72,9 @@
}
\def\@@@@@@subtree{%
\@ifequal{\the\root@node}{\pgfutil@empty}
-\edef\act{\noexpand\@result={\noexpand\pgftree{\noexpand\path coordinate (\noexpand\nodename);}{\the\child@list}}}%
+\edef\act{\noexpand\@result={\noexpand\pgfsubtree{\noexpand\path coordinate (\noexpand\nodename);}{\the\child@list}}}%
\else
-\edef\act{\noexpand\@result={\noexpand\pgftree{\the\root@node}{\the\child@list}}}%
+\edef\act{\noexpand\@result={\noexpand\pgfsubtree{\the\root@node}{\the\child@list}}}%
\fi
\act
\@return}
@@ -105,7 +113,8 @@
\def\@interior.{\@result{\node[alias=\nodename][every tree node,every internal node]}\@label}
-\def\@leaf{\@result{\node[alias=\nodename][every tree node,every leaf node]}\@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\@edge\edge #1;{%
\@result{\edge@adapter{#1}}%
@@ -130,21 +139,13 @@
% predefined edges
-\def\tree@edge#1#2{%
-\ifupsidedown
-(#1.north) -- (#2.south)
-\else
-(#1.south) -- (#2.north)
-\fi
-}
+\def\tree@edge#1#2{(#1.\pgftree@parentanchor) -- (#2.\pgftree@childanchor)}
-\def\roof@edge#1#2{
-\ifupsidedown
-(#1.north) -- (#2.south west) -- (#2.south east) -- cycle
-\else
-(#1.south) -- (#2.north west) -- (#2.north east) -- cycle
-\fi
-}
+\def\roof@edge#1#2{\csname roof@edge@\leveldirection\endcsname{#1}{#2}}
+\def\roof@edge@down#1#2{(#1.south) -- (#2.north west) -- (#2.north east) -- cycle}
+\def\roof@edge@up#1#2{(#1.north) -- (#2.south west) -- (#2.south east) -- cycle}
+\def\roof@edge@left#1#2{(#1.west) -- (#2.north east) -- (#2.south east) -- cycle}
+\def\roof@edge@right#1#2{(#1.east) -- (#2.north west) -- (#2.south west) -- cycle}
%%% Options
@@ -154,10 +155,14 @@
% I don't really like this scheme
\tikzoption{grow}{\csname grow@#1\endcsname}
\tikzoption{grow'}{\csname growprime@#1\endcsname}
-\def\grow@up{\upsidedowntrue\righttolefttrue}
-\def\grow@down{\upsidedownfalse\righttoleftfalse}
-\def\growprime@up{\upsidedowntrue\righttoleftfalse}
-\def\growprime@down{\upsidedownfalse\righttolefttrue}
+\def\grow@up{\def\leveldirection{up}\def\siblingdirection{left}}
+\def\grow@down{\def\leveldirection{down}\def\siblingdirection{right}}
+\def\growprime@up{\def\leveldirection{up}\def\siblingdirection{right}}
+\def\growprime@down{\def\leveldirection{down}\def\siblingdirection{left}}
+\def\grow@left{\def\leveldirection{left}\def\siblingdirection{down}}
+\def\grow@right{\def\leveldirection{right}\def\siblingdirection{up}}
+\def\growprime@left{\def\leveldirection{left}\def\siblingdirection{up}}
+\def\growprime@right{\def\leveldirection{right}\def\siblingdirection{down}}
% defaults appropriate for linguistic trees
\tikzset{every tree node/.style={anchor=base}}