diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/README | 30 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.pdf | bin | 0 -> 107819 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex | 297 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.sty | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex | 110 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgftree.sty | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex | 119 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.sty | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex | 170 |
9 files changed, 740 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-qtree/README b/Master/texmf-dist/doc/latex/tikz-qtree/README new file mode 100644 index 00000000000..6d1fa677a8f --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-qtree/README @@ -0,0 +1,30 @@ +tikztree +David Chiang <chiang at isi dot edu> +Version 1 (22 Dec 2009) + +This package provides a macro for drawing trees with TikZ using the +easy syntax of Alexis Dimitriadis' Qtree. It improves on TikZ's +standard tree-drawing facility by laying out tree nodes without +collisions; it improves on Qtree by adding lots of features from TikZ +(for example, edge labels, arrows between nodes); and it improves on +pst-qtree in being usable with pdfTeX and XeTeX. + +Please see tikztree-manual.pdf for instructions and examples. + +----- + +Copyright (C) 2002, 2009 by David Chiang + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 differnew file mode 100644 index 00000000000..8cbca53ce45 --- /dev/null +++ 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 new file mode 100644 index 00000000000..46c795fb1c7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-qtree/tikz-qtree-manual.tex @@ -0,0 +1,297 @@ +\documentclass{article} + +\usepackage{xltxtra,fontspec} +\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} + +\usepackage{tikz} +\usepackage{tikz-qtree} + +\usepackage{fullpage} + +\usepackage{fancyvrb,fvrb-ex} +\fvset{gobble=0,xleftmargin=0.5in,xrightmargin=2.75in,formatcom=\verbfont} +\VerbatimFootnotes + +\newcommand\tikztree{\texttt{tikz-qtree}} + +\title{\tikztree: better trees with TikZ} +\author{David Chiang} +\date{Version 1 (22 Dec 2009)} + +\begin{document} + +\maketitle + +The \tikztree{} package provides a macro for drawing trees with +TikZ\footnote{\texttt{http://sourceforge.net/projects/pgf/}} using the +easy syntax of Alexis Dimitriadis' +Qtree\footnote{\texttt{http://www.ling.upenn.edu/advice/latex/qtree/}}. It +improves on TikZ's standard tree-drawing facility by laying out tree +nodes without collisions; it improves on Qtree by adding lots of +features from TikZ; and it improves on \verb|pst-qtree| in being +usable with pdf\TeX{} and +\XeTeX{}. + +\section{Basics} + +To load the package in \LaTeX{}: +\begin{Verbatim} +\usepackage{tikz} +\usepackage{tikz-qtree} +\end{Verbatim} +% +The simplest usage is identical to Qtree: +\begin{center} +\begin{SideBySideExample} +\Tree [.S [.NP [.Det the ] [.N cat ] ] + [.VP [.V sat ] + [.PP [.P on ] + [.NP [.Det the ] [.N mat ] ] ] ] ] +\end{SideBySideExample} +\end{center} +Subtrees are delimited by square brackets. A subtree's root label is +joined by a dot (\verb|.|) to its opening bracket.\footnote{You can +also write the label after the closing bracket instead of the opening +bracket, or both, or neither. Please see the Qtree documentation for +details.} As in Qtree, spaces are required after every (internal or +leaf) node label. + +\verb|\Tree| works inside or outside a +\verb|tikzpicture| environment, but many of the features described +below require the explicit \verb|tikzpicture| environment. + +\goodbreak + +\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|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 +writing \verb|[|\textit{option}\verb|=|\textit{value}\verb|]| after a +\verb|\begin{tikzpicture}| or \verb|\begin{scope}|.\footnote{Allowing +options after \verb|\Tree| would have made sense, but there would be +no way to disambiguate the two uses of square brackets.} For example: + +\begin{center} +\begin{SideBySideExample} +\begin{tikzpicture} +\tikzset{level distance=72pt} +\Tree [.NP [.Adj tall ] [.N tree ] ] +\end{tikzpicture} +% +\begin{tikzpicture}[grow'=up] +\Tree [.NP [.Adj upside-down ] [.N tree ] ] +\end{tikzpicture} +\end{SideBySideExample} +\end{center} + +\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: +\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|) +\end{itemize} + +The options for nodes and edges 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: +\begin{center} +\begin{SideBySideExample} +\begin{tikzpicture} +\tikzset{grow'=down} +\tikzset{every leaf node/.style={font=\ar}} +\Tree [.S [.NP القط ] + [.VP [.V وجلس ] + [.PP [.P على ] [.NP حصيرة ] ] ] ] +\end{tikzpicture} +\end{SideBySideExample} +\end{center} +If you want the edges to be darker: +\begin{center} +\begin{SideBySideExample} +\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{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 +\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|, +the child node. +\begin{center} +\begin{SideBySideExample} +\tikzset{edge from parent/.style= + {draw, + edge from parent path={(\tikzparentnode.south) + -- +(0,-8pt) + -| (\tikzchildnode)}}} +\Tree [.S [.NP [.Det the ] [.N cat ] ] + [.VP [.V sat ] + [.PP [.P on ] + [.NP [.Det the ] [.N mat ] ] ] ] ] +\end{SideBySideExample} +\end{center} + +\clearpage + +\section{Embedding TikZ nodes} + +Inside a \verb|\Tree|, in place of a node label, you can use a TikZ +\verb|\node| command.\footnote{\verb|\Tree| specifically watches out +for the token \verb|\node|; do not use \verb|\path node| or other +equivalents.} +\begin{quote} +\verb|\node [|\textit{options}\verb|] (|\textit{name}\verb|) {|\textit{label}\verb|};| +\end{quote} +Don't forget the terminating semicolon. The +\verb|[|\textit{options}\verb|]|, which are optional, let you change +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}; ] + [.C$'$ [.I did ] + [.\node[draw]{IP}; + [.NP [.Det the ] [.N cat ] ] + [.VP [.V sit ] + [.PP [.P on ] + [.\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); +\end{tikzpicture} +\end{Example} +\end{center} + +\clearpage + +\noindent Another example for machine translation people: +\begin{center} +\fvset{formatcom=\javerbfont} +\begin{SideBySideExample} +\begin{tikzpicture} +\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] +\tikzset{every leaf node/.style={font=\ja}} +\Tree [.S [.NP \node(j1){猫が}; ] + [.VP [.PP [.NP [.NP \node(j2){マット}; ] + [.Part \node(j3){の}; ] + [.NP \node(j4){上}; ] ] + [.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 (e4)--(j4); +\draw (e4)--(j5); +\draw (e5)--(j2); +\draw (e6)--(j2); +\end{scope} + +\end{tikzpicture} +\end{SideBySideExample} +\end{center} + +\section{Explicit edges} + +The edge from a parent to a child node is normally automatically drawn +for you, but you can do it yourself with an \verb|\edge| command +\emph{before}\/ the corresponding child node. It is similar to the +TikZ \verb|edge from parent| command.\footnote{Except that a TikZ +\texttt{edge from parent} comes after the child node. I thought it was +more logical to put it before.} +\begin{quote} +\verb|\edge [|\textit{options}\verb|];| +\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: +\begin{quote} +\verb|\edge [|\textit{options}\verb|] node [|\textit{options}\verb|] {|\textit{label}\verb|};| +\end{quote} +Typically one will use the \verb|auto| option for edge labels, which +places the label to the side of the edge. +\begin{center} +\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} + \edge[dashed] node[auto=left]{2}; + [.\auxiliary{on} + \edge node[auto=left]{2}; \initial{mat} ] ] +\end{tikzpicture} +\end{SideBySideExample} +\end{center} +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*{Acknowledgements} +This was all Dan Gildea's idea. + +\section*{Contact} +Please send suggestions to \verb|chiang@isi.edu|. + +\end{document} diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.sty b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.sty new file mode 100644 index 00000000000..500470afc4c --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.sty @@ -0,0 +1,4 @@ +\RequirePackage{pgf} + +\input{pgfsubpic.tex} +\endinput diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex new file mode 100644 index 00000000000..928ae336e95 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex @@ -0,0 +1,110 @@ +% pgfsubpic.tex +% Version 1, 22 Dec 2009 + +% Copyright 2009 by David Chiang + +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. + +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. + +% You should have received a copy of the GNU General Public License along +% with this program; if not, write to the Free Software Foundation, Inc., +% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +\newdimen\pgf@subpicminx +\newdimen\pgf@subpicminy +\newdimen\pgf@subpicmaxx +\newdimen\pgf@subpicmaxy + +% Special virtual node for current subpicture's bounding box +\expandafter\def\csname pgf@sh@ns@current subpicture\endcsname{rectangle} +\expandafter\def\csname pgf@sh@np@current subpicture\endcsname{% + \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@pi@current subpicture\endcsname{\pgfpictureid} + +% Create a pgfpicture inside an hbox for delayed placement +\def\pgfsubpicture{% +\global\setbox\pgf@hbox=\hbox\bgroup +\pgfinterruptpicture% +\pgfpicture% +} + +\def\endpgfsubpicture{ +\global\pgf@subpicminx=\pgf@picminx +\global\pgf@subpicminy=\pgf@picminy +\global\pgf@subpicmaxx=\pgf@picmaxx +\global\pgf@subpicmaxy=\pgf@picmaxy +\global\edef\subpictureid{\pgfpictureid}% +\pgfsetbaseline{\pgf@picminy}% +\endpgfpicture% +\endpgfinterruptpicture% +\egroup +} + +% 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}}% +\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}% +% align origin of subpicture with origin +\pgftransformshift{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}% +\pgfqboxsynced{\pgf@hbox}% +\endpgfscope +} + +% Hook onto existing macro \pgf@shape@interpictureshift. +% 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. +\let\orig@pgf@shape@interpictureshift\pgf@shape@interpictureshift +\def\unwind@subpic#1{% +% is #1 the current picture? +\edef\subpicid{#1}% +\ifx\subpicid\pgfpictureid +% yes, we're done +\else +% does #1 have a parent picture? +\expandafter\ifx\csname pgf@subpic@#1@p\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}% +\fi +\fi +} +\def\pgf@shape@interpictureshift#1{% +\edef\fallback{\pgf@x=\the\pgf@x\pgf@y=\the\pgf@y\noexpand\orig@pgf@shape@interpictureshift{#1}}% +\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}% +} + +\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 +\expandafter\global\expandafter\let\csname pgf@sh@nt@#1\endcsname\relax +\expandafter\global\expandafter\let\csname pgf@sh@pi@#1\endcsname\relax +\expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\relax +} + +\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.sty b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.sty new file mode 100644 index 00000000000..1c30ea4f8c5 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.sty @@ -0,0 +1,6 @@ +\RequirePackage{pgf} +\RequirePackage{pgffor} +\RequirePackage{pgfsubpic} + +\input{pgftree.tex} +\endinput diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex new file mode 100644 index 00000000000..4cdaad16433 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex @@ -0,0 +1,119 @@ +% pgftree.tex +% Version 1, 22 Dec 2009 + +% Copyright 2009 by David Chiang + +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. + +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. + +% You should have received a copy of the GNU General Public License along +% 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 + +\newdimen\levelsep \levelsep=30pt +\newdimen\subtreesep \subtreesep=2pt +\newif\ifrighttoleft +\newif\ifupsidedown +\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}}% +\pgfusepath{stroke}} + +% local variables that we need to assign to inside a \pgfforeach +\newdimen\pgftree@childx +\newdimen\pgftree@savechildx +\newcount\pgftree@childi +\newcount\pgftree@savechildi + +\def\nodename{r} + +%%% \pgftree{root}{subtrees} + +% 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. + +\def\pgftree#1#2{% +\pgfscope +% create root node +#1 +\let\parentnodename\nodename +\ifupsidedown +\pgftransformshift{\pgfpoint{0}{\levelsep}}% +\else +\pgftransformshift{\pgfpoint{0}{-\levelsep}}% +\fi +\pgftree@savechildx=\pgftree@childx +\pgftree@savechildi=\pgftree@childi +\pgfsubpicture +\pgftree@childx=0pt% +\pgftree@childi=0% +{\process@children #2}% +\endpgfsubpicture +\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 +% Draw the edges +\pgftree@childi=0% +{\process@edges #2}% +\fi +\global\pgftree@childi=\pgftree@savechildi +\global\pgftree@childx=\pgftree@savechildx +\endpgfscope +} + +\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 +}% +{\@process@children}% +} +\def\@process@children#1#2{% +\edef\nodename{\parentnodename-\the\pgftree@childi}% +\def\child{#2}% +\pgfsubpicture +#2% +\endpgfsubpicture +\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}}% +\pgfplacesubpicture +\endpgfscope +\advance\pgftree@childx by \ifrighttoleft\pgf@subpicminx\else\pgf@subpicmaxx\fi +\advance\pgftree@childi by 1% +\process@children +} + +\def\process@edges{% +\pgfutil@ifnextchar\egroup +{}% +{\@process@edges}% +} +\def\@process@edges#1#2{% +\edef\nodename{\parentnodename-\the\pgftree@childi}% +#1% +\advance\pgftree@childi by 1% +\process@edges +} diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.sty b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.sty new file mode 100644 index 00000000000..8f572cdb8ee --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.sty @@ -0,0 +1,4 @@ +\RequirePackage{tikz} +\RequirePackage{pgftree} +\input{tikz-qtree.tex} +\endinput diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex new file mode 100644 index 00000000000..6114da8468b --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex @@ -0,0 +1,170 @@ +% tikztree.tex +% Version 1, 22 Dec 2009 + +% Copyright (C) 2002, 2009 by David Chiang + +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. + +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. + +% You should have received a copy of the GNU General Public License along +% with this program; if not, write to the Free Software Foundation, Inc., +% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +%% These macros facilitate building up an object recursively before +%% putting it into the input stream. + +\newtoks\@result +\def\@call#1#2{\let\@cont=#2\bgroup\@result={}#1} +\def\@return{\global\@result=\@result\egroup\@cont} + +\def\@ifequal#1#2{\edef\testa{#1}\edef\testb{#2}\ifx\testa\testb} + +%% scan a tree: this just scans a subtree and then puts it onto the +%% input stream + +\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? +} + +%% scan a subtree +\newtoks\child@list +\newtoks\root@node + +\def\@subtree[{% +\root@node={}% +\pgfutil@ifnextchar.{\@call\@interior\@@subtree}{\@@@subtree}} +\def\@@subtree{% +\root@node=\@result +\@@@subtree +} +\def\@@@subtree{% +\@call\@children\@@@@subtree +} +\def\@@@@subtree]{% +\child@list=\@result +\pgfutil@ifnextchar.{\@call\@interior\@@@@@subtree}{\@@@@@@subtree}} +\def\@@@@@subtree{% +%%% Check for mismatch. +\@ifequal{\the\root@node}{\pgfutil@empty}% + \root@node=\@result +\fi +\@ifequal{\the\root@node}{\the\@result}\else + \message{Warning: mismatched labels, \the\root@node{} and \the\@result.}% +\fi +\@@@@@@subtree +} +\def\@@@@@@subtree{% +\@ifequal{\the\root@node}{\pgfutil@empty} +\edef\act{\noexpand\@result={\noexpand\pgftree{\noexpand\path coordinate (\noexpand\nodename);}{\the\child@list}}}% +\else +\edef\act{\noexpand\@result={\noexpand\pgftree{\the\root@node}{\the\child@list}}}% +\fi +\act +\@return} + +%% scan a sequence of subtrees or leaves + +\newif\ifscanned@edge + +\def\@children{% +\scanned@edgefalse +\child@list{}% +\@@children} +\def\@@children{% +\pgfutil@ifnextchar]{\@result\child@list\@return}{% end of children +\pgfutil@ifnextchar\edge{% explicit edge +\ifscanned@edge +\message{Warning: more than one edge given for a single child}\let\next\@@children % ignore +\else +\scanned@edgetrue\let\next\@@@children +\fi +\@call\@edge\next}{% +% else, a real node is next +\ifscanned@edge\else % no explicit edge, supply default +\expandafter\child@list\expandafter{\the\child@list{\edge@adapter{}}}% +\fi +\scanned@edgefalse +\pgfutil@ifnextchar[{\@call\@subtree\@@@children}% subtree +{\@call\@leaf\@@@children} % leaf +}}} +\def\@@@children{% +% wrap child inside curly braces +\expandafter\@result\expandafter{\expandafter{\the\@result}} +\edef\act{\noexpand\child@list{\the\child@list \the\@result}}\act +\@@children +} + +\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\@edge\edge #1;{% +\@result{\edge@adapter{#1}}% +\@return} +\def\edge@adapter#1{% +\let\tikzparentnode\parentnodename +\let\tikzchildnode\nodename +\path edge from parent #1;% +} + +% a label is either text or PGF/TikZ code starting with \node +\def\@label{\pgfutil@ifnextchar\node{\@litlabel}{\@@label}} +\def\@@label#1 {% +\expandafter\@result\expandafter{\the\@result{#1};}% +\@return} + +% try to copy \node command into \@result without stripping braces +\def\@litlabel\node{\@@litlabel} +\def\@@litlabel{\pgfutil@ifnextchar\bgroup{\@@@litlabel}{\@@@@litlabel}} +\def\@@@litlabel#1{\expandafter\@result\expandafter{\the\@result {#1}}\@@litlabel} +\def\@@@@litlabel#1;{\expandafter\@result\expandafter{\the\@result #1;}\@return} + +% predefined edges + +\def\tree@edge#1#2{% +\ifupsidedown +(#1.north) -- (#2.south) +\else +(#1.south) -- (#2.north) +\fi +} + +\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 +} + +%%% Options + +\tikzoption{level distance}{\pgfmathsetlength\levelsep{#1}} +\tikzoption{sibling distance}{\pgfmathsetlength\subtreesep{#1}} % different semantics + +% 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} + +% defaults appropriate for linguistic trees +\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}}} + |