diff options
author | Karl Berry <karl@freefriends.org> | 2007-04-11 23:00:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-04-11 23:00:26 +0000 |
commit | 8f31805c4ce61cf93939e49037d89b690948c840 (patch) | |
tree | 87b028baf99a593eaac5ad243eacd0a7dd77d240 /Master/texmf-dist/tex | |
parent | 4b9b1bcdd965d2220397723d248a8c0e7a4cdd32 (diff) |
new package pst-qtree (11apr07)
git-svn-id: svn://tug.org/texlive/trunk@4147 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-qtree/pst-qtree.tex | 153 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pst-qtree/pst-qtree.sty | 23 |
2 files changed, 176 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pst-qtree/pst-qtree.tex b/Master/texmf-dist/tex/generic/pst-qtree/pst-qtree.tex new file mode 100644 index 00000000000..8dd7ff5771b --- /dev/null +++ b/Master/texmf-dist/tex/generic/pst-qtree/pst-qtree.tex @@ -0,0 +1,153 @@ +% pst-qtree.tex +% Copyright (C) 2002 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. + + +\psset{nodesep=2pt,levelsep=36pt,treesep=24pt} +%\def\psedge{\ncdiag[arm=0,angleA=-90,angleB=90]} +\def\psnode#1{\TR{#1}} + +\edef\TheAtCode{\the\catcode`\@} +\catcode`\@=11 + +\newtoks\result + +%% These macros facilitate building up an object recursively before +%% putting it into the input stream. + +\def\call#1#2{\let\@cont=#2\bgroup\result={}#1} +\def\return{% +\global\result=\result +\egroup\@cont +} + +\def\ifeq#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{% +\ifeq{\psk@treemode}{0}% + \def\psedge{\ncdiag[arm=0,angleA=-90,angleB=90]} +\fi +\ifeq{\psk@treemode}{2}% if \psset{treemode=U} + \def\psedge{\ncdiag[arm=0,angleA=90,angleB=-90]} +\fi +\ifeq{\psk@treemode}{1}% if \psset{treemode=R} + \def\psedge{\ncdiag[arm=0,angleA=0,angleB=180]} +\fi +\ifeq{\psk@treemode}{3}% if \psset{treemode=L} + \def\psedge{\ncdiag[arm=0,angleA=180,angleB=0]} +\fi +\call\@subtree\@Tree} +\def\@Tree{\the\result} + +%% scan a subtree + +\def\@subtree[{% +\toks0={\@nil}% +\@ifnextchar.{\call\@dotlabel\@@subtree}{\@@@subtree}} + +\def\@@subtree{% +\toks0=\result +\@@@subtree +} + +\def\@@@subtree{% +\call\@children\@@@@subtree +} + +\def\@@@@subtree]{% +\toks2=\result +\@ifnextchar.{\call\@dotlabel\@@@@@subtree}{\@@@@@@subtree}} + +\def\@@@@@subtree{% +%%% Check for mismatch. +\ifeq{\the\toks0}{\noexpand\@nil}% + \toks0=\result +\fi +\ifeq{\the\toks0}{\the\result}\else + \message{Warning: mismatched labels, \the\toks0{} and \the\result.}% +\fi +\@@@@@@subtree +} + +\def\@@@@@@subtree{% +\ifeq{\the\toks0}{\noexpand\@nil}% + \edef\act{\noexpand\result={\noexpand\pstree{\noexpand\psnode{}}{\the\toks2}}}% +\else + \edef\act{\noexpand\result={\noexpand\pstree{\the\toks0}{\the\toks2}}}% +\fi +\act +\return} + +%% scan a sequence of subtrees or leaves + +\def\@children{% +\@ifnextchar]{\return}{% +\@ifnextchar[{\call\@subtree\@@children}{\call\@label\@@children}}} + +\def\@@children{% +\toks0=\result +\call\@children\@@@children +} + +\def\@@@children{% +\ifeq{\the\toks0}{}% +\else + \toks2=\result + \edef\act{\noexpand\result={\the\toks0 \the\toks2}}% + \act +\fi +\return +} + +%% scan an interior label + +\def\@dotlabel.{% +\@label +} + +%% scan a leaf node + +\def\@label{% +\@ifnextchar!{\@litlabel}{\@@label}} + +\def\@@label#1 {% +\result={\psnode{\hbox{\begin{tabular}{c} #1 \end{tabular}}}}% +\return +} + +\def\@litlabel!#1 {% +\result={#1}% +\return +} + +\def\roofedge#1#2{% +\ncdiag[arm=0pt,angleA=-90,angleB=90]{#1}{#2l} +\ncdiag[arm=0pt,angleA=-90,angleB=90]{#1}{#2r} +\ncdiag[arm=0pt,angleA=90,angleB=90]{#2l}{#2r}} + +\def\Troof#1{% +\TR[edge=\roofedge]{% +\Rnode[href=-1]{\pspred-\the\psnodecnt l} +{\Rnode[href=1]{\pspred-\the\psnodecnt r}{#1}}}% +} + +\catcode`\@=\TheAtCode\relax +\endinput + diff --git a/Master/texmf-dist/tex/latex/pst-qtree/pst-qtree.sty b/Master/texmf-dist/tex/latex/pst-qtree/pst-qtree.sty new file mode 100644 index 00000000000..de77803ae3d --- /dev/null +++ b/Master/texmf-dist/tex/latex/pst-qtree/pst-qtree.sty @@ -0,0 +1,23 @@ +% pst-qtree.sty +% Copyright (C) 2002 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. + +\ProvidesPackage{pst-qtree} +\usepackage{pst-node} +\usepackage{pst-tree} +\input pst-qtree.tex +\endinput + |