diff options
author | Karl Berry <karl@freefriends.org> | 2009-12-31 01:40:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-12-31 01:40:09 +0000 |
commit | f84374dfd46b282099b639296e3b952f4d52746f (patch) | |
tree | 5494a9c99e49aad4e33ed49bc04f36b78bb03b6e /Master | |
parent | e70f23cf27d400ee9d1cd7afa8fa7de6896c1b69 (diff) |
tikz-qtree update (26dec09)
git-svn-id: svn://tug.org/texlive/trunk@16546 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/README | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/test.pdf | bin | 0 -> 6035 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/test.tex | 45 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf | bin | 107819 -> 128672 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex | 98 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex | 116 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex | 167 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree-compat.sty | 72 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex | 53 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 2 |
10 files changed, 470 insertions, 98 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/README b/Master/texmf-dist/doc/latex/tikz-qtree/README index 6d1fa677a8f..ac07f36ac05 100644 --- a/Master/texmf-dist/doc/latex/tikz-qtree/README +++ b/Master/texmf-dist/doc/latex/tikz-qtree/README @@ -1,6 +1,6 @@ -tikztree +tikz-qtree David Chiang <chiang at isi dot edu> -Version 1 (22 Dec 2009) +Version 1.1 (Christmas 2009) This package provides a macro for drawing trees with TikZ using the easy syntax of Alexis Dimitriadis' Qtree. It improves on TikZ's @@ -11,6 +11,17 @@ pst-qtree in being usable with pdfTeX and XeTeX. Please see tikztree-manual.pdf for instructions and examples. +Version history: + +1.1 (2009/12/25): + - much deeper trees can be typeset without exceeding capacity + - sideways trees + - extra package for improved Qtree compatibility + - connections can be drawn to whole subtrees instead of nodes + +1 (2009/12/22): + - initial release + ----- Copyright (C) 2002, 2009 by David Chiang diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/test.pdf b/Master/texmf-dist/doc/latex/tikz-qtree/test.pdf Binary files differnew file mode 100644 index 00000000000..ca86b5ba74e --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-qtree/test.pdf diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/test.tex b/Master/texmf-dist/doc/latex/tikz-qtree/test.tex new file mode 100644 index 00000000000..77220a844db --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-qtree/test.tex @@ -0,0 +1,45 @@ +\documentclass{article} + +\usepackage{tikz,tikz-qtree} +\usepackage{pgf,pgfsubpic} + +\begin{document} + +\fbox{% +\begin{pgfpicture} +\pgfnode{rectangle}{center}{Hello}{hellonode}{\pgfusepath{stroke}} +\begin{pgfsubpicture} +\pgfpathcircle{\pgfpointorigin}{4pt}\pgfusepath{stroke} +\pgfnode{rectangle}{center}{there}{therenode}{\pgfusepath{stroke}} +\end{pgfsubpicture} +\pgftransformshift{\pgfpoint{1in}{-1in}} +\pgftransformscale{2} +\pgftransformrotate{45} +\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepath{fill} +\pgfplacesubpicture + +\pgfmoveto{\pgfpointanchor{hellonode}{south}} +\pgflineto{\pgfpointanchor{therenode}{north}} +\pgfusepath{stroke} + +\end{pgfpicture}% +} + +\begin{tikzpicture} +\begin{pgfscope} +\begin{pgfsubpicture} +\draw (-1in,0)--(2in,0)--(2in,2in)--(0,2in)--cycle; +\end{pgfsubpicture} +\pgffitsubpicture{\pgfpointorigin}{\pgfpoint{1in}{1in}} +\pgfplacesubpicture +\end{pgfscope} + +\draw (0,0)--(1in,0)--(1in,1in)--(0,1in)--cycle; + + +\end{tikzpicture} + + + + +\end{document} 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 8cbca53ce45..9d4d073d0bc 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 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|. 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}} diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 3676866ec7f..60468ad8438 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -1022,7 +1022,7 @@ $standardtex='\.(cfg|sty|clo|ldf|cls|def|fd|cmap|4ht)$'; 'tex-ewd', 'dotnot.tex', 'texsis', '\.txs|TXS.*tex|texsis.tex', 'ticket', '\.tdf|' . $standardtex, - 'tikz-qtree', '(pgf|tikz-)(subpic|q?tree)\.(tex|sty)', + 'tikz-qtree', '(pgf|tikz-)(subpic|q?tree(-compat)?)\.(tex|sty)', 'tkz-doc', '\.cls', # no example.sty 'tools', '\.cfg|\.sty|\.clo|\.cls|\.def|\.fd$|.?\.tex|^\.tex$', 'translator', '\.dict|translator-language-mappings.tex|' . $standardtex, |