summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/linguex/ps-trees.sty
blob: 6f31dffcf9e8a1f7464cf7181588220daff8458f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
%% Copyright  1999 Wolfgang Sternefeld
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt; either
%% version 1 of the License, or any later version.
%% ps-trees.sty version 2.0
%% Author: Wolfgang.Sternefeld@uni-tuebingen.de
%% filedate 99/27/04
\ProvidesPackage{ps-trees}[1999/04/27 Linguistic trees in tabular form v. 2.0]
\RequirePackage{tree-dvips}
\newtoks\AllNodes
\newtoks\CollectedNodes
\newtoks\CollectedTNodes
\newif\ifIsElement
\newlength{\MinNodeWidth}
\newlength{\NodeWidth}
\newcommand{\NodeWidthNo}[1]{\setlength{\MinNodeWidth}{\the\wd#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifTNode
\newcommand{\AddToToks}[2]{%
      \expandafter\expandafter\expandafter%
        \global#1\expandafter{%
          \the#1#2}}
\def\TestAndAdd#1{\def\yy{#1}%
     \ifx\yy\empty\relax\else%
       \ifTNode\AddToToks{\CollectedTNodes}{\\{#1}}%
          \else\AddToToks{\CollectedNodes}{\\{#1}}\fi\fi
     \IfIsNodeName{#1}%
      \typeout{*** Warning: Node Name `#1' already exists ***}\fi
    }
\let\oldnode=\node
\newenvironment{psTree}{\tabcolsep0pt\nodemargin0pt%    
    \def\node##1##2{\AddToToks{\AllNodes}{\\{##1}}\oldnode{##1}{##2\strut}}%
    }%
   {\let\\=\EveryNode\the\CollectedNodes%
           \let\\=\EveryTNode\the\CollectedTNodes%
    \global\AllNodes={}\global\CollectedNodes={}\global\CollectedTNodes={}%
    \global\setlength{\MinNodeWidth}{0pt}%\hspace{\fill}
    }
\newcommand{\EveryNode}[1]{\ConnectNode#1 }
\newcommand{\EveryTNode}[1]{\ConnectTNode#1 }
\def\ConnectNode#1#2 {\IfIsNodeName{#2}\nodeconnect{#2}{#1#2}%
     \else\NoNodeWarning{#2}\fi}
\def\ConnectTNode#1#2 {\IfIsNodeName{#2}\nodeconnect{#2}[tl]{#1#2}%
       \nodeconnect{#2}[tr]{#1#2}\nodeconnect[tl]{#1#2}[tr]{#1#2}%
     \else\NoNodeWarning{#2}\fi}
\newcommand{\IsElementOf}[2]{\IsElementfalse\def\xx{#1}\bgroup
     \let\\=\Compare\the#2\egroup}
\newcommand{\IfIsNodeName}[1]{\IsElementOf{#1}{\AllNodes}\ifIsElement}
\newcommand{\Compare}[1]{\def\yy{#1}\ifx\yy\xx\global\IsElementtrue\fi}
\newcommand{\NoNodeWarning}[1]{\typeout{*** Fatal Error. Node Name `#1'
     does'nt exist ***}}
\newenvironment{treetab}{\begin{psTree}\begin{tabular}}{\end{tabular}%
     \end{psTree}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\Node}{\@ifnextchar[{\OptionNode}{\@Node}}
\newcommand{\@Node}[2]{\TestAndAdd{#1}\settowidth{\NodeWidth}{#2}%
  \ifdim\NodeWidth<\MinNodeWidth% 
       \makebox[\MinNodeWidth]{\hfill\node{#1}{#2}\hfill}%
     \else\node{#1}{#2}%
  \fi}
\def\OptionNode[#1]#2#3{\TestAndAdd{#2}\makebox[\the\wd#1]{\hfill
           \node{#2}{#3}\hfill}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\NodeNo}[1]{\@ifnextchar[{\OptionNodeNo{#1}}{\@NodeNo{#1}}}
\newcommand{\@NodeNo}[2]{\@Node{#2}{\unhcopy#1}}
\def\OptionNodeNo#1[#2]#3{\TestAndAdd{#3}%
     \makebox[\the\wd#2]{\hfill\node{#3}{\unhcopy#1}\hfill}}
\newcommand{\NodeZ}[2]{\TestAndAdd{#1}%
     \hfill\node{#1}{\makebox[0pt]{#2\strut}}}
\newcommand{\NodeT}[2]{\TNodetrue
      \Node{#1}{#2}\TNodefalse}
\newcommand{\NodeZT}[2]{\TNodetrue\TestAndAdd{#1}%
     \hfill\makebox[0pt]{\node{#1}{#2\strut}}\TNodefalse}
\let\NodeTZ=\NodeZT
\newcommand{\NodeTNo}[2]{\TNodetrue\NodeNo{#1}{#2}\TNodefalse}
\newcommand{\NodeZTNo}[2]{\hfill\makebox[0pt]{\NodeTNo{#1}{#2}}}
\let\NodeTZNo=\NodeZTNo
\newcommand{\nodeZ}[2]{\IfIsNodeName{#1}%
       \typeout{*** Warning: Node Name `#1' already exists ***}\fi
     \hfill\node{#1}{\makebox[0pt]{#2}}}
%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%