summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/rrgtrees/rrgtrees.sty
blob: fbed1dfbf08af936229e49b456d7d5d8843ae37c (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
%%
%% This is file `rrgtrees.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% rrgtrees.dtx  (with options: `package')
%% Copyright (c) D. J. Gardner 2001-2004
%% 
%% This program may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% This program consists of the files rrgtree.dtx and rrgtree.ins
%% 
%% 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.
%% 
%% Error reports in case of UNCHANGED versions to
%% David Gardner:  djardner at softhome dot net
%% rrgtrees.dtx.  Copyright (c) D. J. Gardner 2001-2004


\def\rrgversion{1.1}
\def\rrgversiondate{Nov 14 2004}
\def\rrgdocversiondate{Dec 14 2004}
\ProvidesPackage{rrgtrees}[2004/11/14 RRG tree drawing]
\RequirePackage{pst-node,pst-tree}
\newcommand{\pred}[2][]{\textbf{#2}\ensuremath{'_{#1}}}
\newcommand\SEML{\textsf{SEML}\,}
\newcommand\INGR{\textsf{INGR}\,}
\newcommand\BECOME{\textsf{BECOME}\,}
\newcommand\CAUSE{\textsf{CAUSE}\,}
\newcommand\NOT{\textsf{NOT}\,}
\newcommand\prddo{\pred{do}}
\newcommand\prdDO{\pred{DO}}
\def\Sentence{{\scshape Sentence}}
\def\Clause{{\scshape Clause}}
\def\Core{{\scshape Core}}
\def\Conj{{\scshape Conj}}
\def\CMPLtext{{\scshape cmpl}}
\def\Nuc{{\scshape Nuc}}
\def\Arg{{\scshape Arg}}
\def\aaj{{\scshape AAJ}}
\def\pp{{\scshape PP}}
\def\np{{\scshape NP}}
\def\Periphery{{\scshape Periphery}}
\newlength\rrgoprsep
\newlength\rrg@tmpdim
\newlength\rrg@tmpdima
\newlength\rrg@tmpdimb
\setlength{\rrgoprsep}{1.5em}
\def\rrg@empty@toks{\global\let\rrg@dolinks\@empty}
\rrg@empty@toks
\def\dolinks{\rrg@dolinks\rrg@empty@toks}
\def\@once@tmp{}
\def\rrg@addlinks{\g@addto@macro\rrg@dolinks}
\newcommand{\rrg@newnode}[1]{\@namedef{rrg@node@#1}{\null}}
%%Broken code:
%%\newcommand{\rrg@do@or@add@link}[3]{\@ifundefined{rrg@node@#1}{\typeout{#1
%% undefined}\rrg@addlinks{#3}}{\@ifundefined{rrg@node@#2}
%% {\typeout{#2 undefined}\rrg@addlinks{#3}}{#3}}}

\newcommand{\rightangle@link}[7]{
\settowidth{\rrg@tmpdim}{#4}%
\skiplevels{#1}%
\rrg@newnode{#2}%
\ifdim\rrg@tmpdim>0pt
\pstree{\TR[edge=none, name=#2]{#4}}{%
#5}%
\else%
\TR[edge=none,name=#2]{#5}%
\fi%
\endskiplevels%
\rrg@addlinks{\ncangle[angleA=90,angleB=#7,armB=0]{->}{#2}{#3}%
\ncput*[npos=1]{#6}}}

\newcommand{\diag@link}[8]{
\settowidth{\rrg@tmpdim}{#4}%
\expandafter\typeout{\the\rrg@tmpdim}
\skiplevels{#1}%
\rrg@newnode{#2}%
\ifdim\rrg@tmpdim>0pt
\pstree{\TR[edge=none, name=#2]{#4}}{%
#5}%
\else%
\typeout{#4:#5}%
\TR[edge=none,name=#2]{#5}%
\fi%
\endskiplevels%
\rrg@addlinks{\ncdiagg[angleA=#7,armA=#8]{<-}{#3}{#2}%
\ncput*[npos=1]{#6}}}
\newcommand{\@NUCa}[3]{\pstree{\TR{\@do@once\Nuc}}{
\pstree{\TR{#1}}{\pstree{\TR[name=verb]{\ncput*[npos=1.5]{\scshape{Pred}}#2}}{#3}}}}
\newcommand{\@NUCn}[2]{\pstree{\TR{\@do@once\Nuc}}{\pstree{\TR{#1}}%
{\TR[name=verb]{\ncput*[npos=1.5]{\scshape{Pred}}#2}}}}

\newcommand{\CMPL}[3][CLAUSE]{\rightangle@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{180}}
\newcommand{\lCMPL}{\CMPL}
\newcommand{\rCMPL}[3][CLAUSE]{\rightangle@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{0}}
\newcommand{\LCMPL}[4][CLAUSE]{\diag@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{180}{#4}}
\newcommand{\RCMPL}[4][CLAUSE]{\diag@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{0}{#4}}
\newcommand{\lPERIPH}[4][]{\rightangle@link{#2}{PERIPH#1}{CORE#1}%
{#3}{#4}{\Periphery}{180}}
\newcommand{\rPERIPH}[4][]{\rightangle@link{#2}{PERIPH#1}{CORE#1}%
{#3}{#4}{\Periphery}{0}}
\newcommand{\LPERIPH}[5][]{\diag@link{#2}{PERIPH#1}{CORE#1}{#3}%
{#4}{\Periphery}{180}{#5}}
\newcommand{\RPERIPH}[5][]{\diag@link{#2}{PERIPH#1}{CORE#1}{#3}%
{#4}{\Periphery}{0}[#5]}

\newcommand{\NUC}[2][V]{\@ifnextchar\bgroup{\@NUCa{#1}{#2}}{\@NUCn{#1}{#2}}}
\newcommand{\TOP}[1]{\pstree[thislevelsep=0pt,linestyle=none]{\Tn}%
{\psset{linestyle=solid}#1}}
\newcommand{\SENTENCE}[2][SEN]{\pstree{\TR[name=#1]{\Sentence}\@do@once}{#2}}
\newcommand{\CLAUSE}[2][CLS]{\pstree{\TR[name=#1]{\Clause}\@do@once}{#2}}
\newcommand{\CORE}[2][CORE]{\pstree{\TR[name=#1]{\Core}\@do@once}{#2}}
\newcommand{\ARG}[2][arg]{\pstree{\TR[name=#1]{\Arg}\@do@once}{#2}}
\newcommand{\AAJ}[2][aaj]{\pstree{\TR[name=#1]{\aaj}\@do@once}{#2}}
\newcommand{\PP}[2][PP]{\pstree{\TR[name=#1]{\pp}\@do@once}{#2}}
\newcommand{\NP}[2][NP]{\pstree{\TR[name=#1]{\np}\@do@once}{#2}}
\newcommand{\NCORE}[2][NC]{\pstree{\TR[name=#1]{\Core\subN}\@do@once}{#2}}
\newcommand{\NNUC}[2][NN]{\pstree{\TR[name=#1]{\Nuc\subN}\@do@once}{#2}}
%% |\WORD| tries to be flexible in the arguments it gets.
%% The user may optionally include the (part of speach) a |[name]| for the
%% |{word}| node, and possibly being followed by an |{operator projection}|.
%% E.g. |\WORD{hello}|, |\WORD[hi]{hello}|, |\WORD(N){cat}|,
%% |\WORD(N)[pussy]{cat}|
%% are all permitted, as is any of the above with an operator projection
\newcommand{\WORD}{\let\@word@tmp=\empty\@ifnextchar(%) bracket match
{\@word@ii}{\@word@i}}
\newcommand{\@word@i}[2][x]{\@end{#1}{#2}} % Nice easy single level word
\def\@word@ii(#1){\@ifnextchar[%] bracket match % we have a fuller tree.
{\@word@iii{#1}}{\@word@iii{#1}[x]}}
\def\@word@iii#1[#2]#3{\@ifnextchar\bgroup% operators follow
{\@word@iv{#1}{#2}{#3}}{\pstree{\TR{#1}\@do@once}{\TR[name=#2]{#3}}}}

\newcommand{\@word@iv}[4]{\pstree{\TR{#1}\@do@once}{\pstree{\TR[name=#2]{#3}}{#4}}}
\newcommand{\@do@once}{\@once@tmp\def\@once@tmp{}}
\newcommand{\UNJOINED}{\def\@once@tmp{\global\let\psedge\@save@edge}%
\let\@save@edge\psedge\def\psedge##1##2{}}
\newcommand{\OPR}[3][opr]{\skiplevels{#2}{\TR[edge=none,name=#1]{#3}}\endskiplevels}
\newcommand\OP[2][op]{\psset{levelsep=\rrgoprsep}\@end{#1}{\@do@once#2}}
\newcommand{\oprlink}[4]{%
\ncput*[npos=1 #1]{\rnode{label}{#4}}%
\ncline[linestyle=dashed]{#2}{label}\ncline{->}{label}{#3}%
}
\newcommand{\LLINK}[5][]{%
\ncdiagg[linestyle=none,angleA=180,armA=#2]{#4}{#3}%
\oprlink{#1}{#3}{#4}{#5}
}
\newcommand{\RLINK}[5][]{%
\ncdiagg[linestyle=none,angleA=0,armA=#2]{<-}{#4}{#3}%
\oprlink{#1}{#3}{#4}{#5}
}
\newcommand{\rLINK}[4][]{\ncangle[linestyle=none,angleA=-90,angleB=0 #1]{#2}{#3}%
\oprlink{}{#2}{#3}{#4}
}
\newcommand{\LINK}[4][]{\ncangle[linestyle=none,angleA=-90,angleB=180 #1]{#2}{#3}%
\oprlink{}{#2}{#3}{#4}
}
\newcommand{\lLINK}{\LINK}
\newcommand{\End}[2][x]{\@end{#1}{#2}}

\newcommand{\@end}[2]{\@ifnextchar\bgroup% matching
{\@are@ops{#1}{#2}}{\@end@{#1}{#2}}}
\newcommand{\@end@}[2]{\TR[name=#1]{#2}}
\def\@are@ops#1#2#3{\pstree{\@end@{#1}{#2}}{#3}}
\def\rrgfantweak{-1pt}
\newcommand{\FanEnd}[3][fan]{%
\@ifnextchar\bgroup{\@fanend{#1}{#2}{#3}}{\@@fanend{#1}{1}{#2}{#3}}}
\def\@fanend#1#2#3#4{\@@fanend{#1}{#2}{#3}{#4}}
\newcommand{\@@fanend}[4]{
\setbox\@tempboxa\hbox{#4}%
\setlength{\rrg@tmpdim}{\wd\@tempboxa}%
\addtolength{\rrg@tmpdim}{-1ex}%
\setlength{\rrg@tmpdimb}{\psk@levelsep}%
\setlength{\rrg@tmpdima}{\psk@levelsep}%
\setlength{\rrg@tmpdimb}{#2\rrg@tmpdima}%
\addtolength{\rrg@tmpdimb}{+0.7ex}%
\addtolength{\rrg@tmpdimb}{-\ht\@tempboxa}%
\addtolength{\rrg@tmpdimb}{-\pslabelsep}%
\addtolength{\rrg@tmpdimb}{\rrgfantweak}%
\pstree[thislevelsep=\rrg@tmpdimb]{\TR{#3}}{\Tfan[fansize=\rrg@tmpdim]%
\nbput*[npos=1.5,name=#1]{#4}}
}
\DeclareRobustCommand*\textsubscript[1]{%
  \@textsubscript{\selectfont#1}}
\def\@textsubscript#1{%
  {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
\newcommand{\spr}[1]{\textsuperscript{#1}}
\newcommand{\sub}[1]{\textsubscript{#1}}
\newcommand{\subN}{\textsubscript{\scshape{n}}}
%%Args for |\OPJoin| are:
%% [Offset from centre] \{node\} \{node\} \{Text/structure\}
\newcommand{\OPJoin}[4][2\rrgoprsep]{\ncline[linestyle=none]{#2}{#3}%
\nbput[labelsep=#1,npos=0.5]{\Rnode{join-#2-#3}{#4}%
}\ncline[linestyle=solid]{#2}{join-#2-#3}%
\ncdiag[armA=0,armB=0]{#3}{join-#2-#3}}
\def\psedge{\ncdiag}
\psset{levelsep=3.5em,nodesep=1pt,angleA=-90,angleB=90,armA=0,armB=0}
\endinput
%%
%% End of file `rrgtrees.sty'.