Debian Codegraph @

texmf-dist/source/latex/rrgtrees/rrgtrees.dtx

raw
1 % \iffalse meta-comment
2 %% rrgtrees.dtx. Copyright (c) D. J. Gardner 2001-2004
3 %
4 % This program may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.2
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.2 or later is part of all distributions of LaTeX
10 % version 1999/12/01 or later.
11 %
12 % This program consists of the files rrgtrees.dtx and rrgtrees.ins
13
14 % This program is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 %
18 % Changes:
19 % Dec 2001: Current codebase finished
20 % Jul 2002: Try making dtx file. Give up with lack of time, examples and docs.
21 % Nov 2004: Have another go, and succeed. Add |\SEML| command.
22 %
23
24 % \CharacterTable
25 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
26 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
27 % Digits \0\1\2\3\4\5\6\7\8\9
28 % Exclamation \! Double quote \" Hash (number) \#
29 % Dollar \$ Percent \% Ampersand \&
30 % Acute accent \' Left paren \( Right paren \)
31 % Asterisk \* Plus \+ Comma \,
32 % Minus \- Point \. Solidus \/
33 % Colon \: Semicolon \; Less than \<
34 % Equals \= Greater than \> Question mark \?
35 % Commercial at \@ Left bracket \[ Backslash \\
36 % Right bracket \] Circumflex \^ Underscore \_
37 % Grave accent \` Left brace \{ Vertical bar \|
38 % Right brace \} Tilde \~}
39 %<*driver>
40 \documentclass[draft]{ltxdoc}
41 \DeclareRobustCommand\package[1]{\textsf{#1}}
42 \usepackage{rrgtrees}
43 \usepackage{geometry}
44 \geometry{a4paper,hmargin=2cm,vmargin=2cm,nohead}
45 \begin{document}
46 \title{\textsf{RRG trees} package\\Version \rrgversion\small\rrgversiondate}
47 \author{D.J.Gardner}\date{Document date: \rrgdocversiondate}\maketitle
48 \DeclareRobustCommand\package[1]{\textsf{#1}}
49 \DocInput{rrgtrees.dtx}
50 \end{document}
51 %</driver>
52 %<*package>
53 % \fi
54 % \StopEventually{}
55 \def\rrgversion{1.1}
56 \def\rrgversiondate{Nov 14 2004}
57 \def\rrgdocversiondate{Dec 14 2004}
58 % \iffalse meta-comment
59 %</package>
60 % \fi
61 %
62 %\section{Introduction}
63 %This package provides a simplified interface to pstricks module pst-tree
64 %for drawing the complex syntactic trees found in RRG.
65 %
66 %Role and Reference Grammar is a grammatical (syntactic) theory of human
67 %language that, unlike certain other theories, does not make every language
68 %look like English. It also acknowledges that certain syntactic phenomena
69 %cannot be accounted for except by reference to semantic and pragmatic
70 %considerations. As such is well suited to the analysis of
71 %languages with features like: free word order; interesting split
72 %ergative/accusative systems; pragmatic and/or semantic case assignment;
73 %switch-reference systems
74 %and minority languages in general. For further details, see e.g.
75 %``Syntax'', Van Valin and LaPolla, Cambridge University Press:Cambridge
76 %1993.
77 %
78 %In \LaTeX\ terms, the most challenging aspect of it is that it allows (nay,
79 %rejoices in having!) syntactic trees which have lines that cross, and also
80 %has an ``operator projection'' that is a distinct representation from the
81 %syntactic tree of clause, NPs, etc. While it would be possible to draw
82 %these with a graphics package, the nice features of \LaTeX\ that might
83 %allow the tree to self-scale to the document font, and adjust its
84 %parameters depending on the font used and which words are to be displayed
85 %would be lost. Such diagrams are not easy to
86 %construct using the \package{pst-tree} (part of pstricks) macros, but are
87 %possible by carefully combining \package{pst-tree} with some
88 %\package{pst-node} commands. The flexibility of \package{pst-tree} in
89 %allowing any number of decendent nodes, unlike other tree packages I've
90 %found, is clearly important for ease of use with language data.
91 %This package aims to make RRG trees far easier to construct than would be
92 %possible using the raw commands.
93 %
94 %The package also provides macros for displaying and typesetting other
95 %representations used in RRG, such as the \pred{pred}() style of elements
96 %used in logical structures.
97 %
98 %\section{Drawing Basic Trees}
99 %An attempt has been made to make the commands for drawing trees and
100 %tree-elements relatively simple, while allowing flexibility. If the full
101 %flexibility of the \package{pst-node} and \package{pst-tree} commands is required, there
102 %should be no problem of mixing those in, indeed some complex constructions
103 %will need to use direct \package{pst-node} and \package{pst-tree} commands.
104 %
105 %It may be helpful to think of the commands as being divided between two
106 %categories: tree-building and line drawing; or alternatively between the
107 %operator projection commands, and the syntactic structure commands.
108 %Actually these two are pretty much orthogonal, and thus we have four
109 %groups of commands, although there is considerable fuzziness at the edges
110 %(e.g. line drawing commands which also include tree building elements, and
111 %tree elements that require some line drawing).
112 %
113 %\subsection{Basic Commands}
114 %The following example produces the layered structure for
115 %`the cat walked to the mat', but marks the final PP as unanalysed with a
116 %triangle. Normal font changing commands work and
117 %the separation between levels and nodes of the tree may be changed using
118 %the normal pst-tree settings. In the example, the left-hand version was
119 %produced by preceeding the commands with \verb+\psset{treesep=2ex}+,
120 %the right-hand by preceeding them with
121 %\verb+\small\bfseries+ \verb+\psset{treesep=2ex+, \verb+levelsep=3em}+.
122 %
123 %\begin{center}
124 %\DeleteShortVerb{\|}
125 %\begin{tabular}{p{0.33\textwidth}c|c}
126 %\begin{verbatim}
127 %\CLAUSE{
128 % \CORE{
129 % \OPR{2}{the}
130 % \ARG{\WORD(NP){cat}}
131 % \NUC{walked}
132 % \AAJ{
133 % \FanEnd{PP}{to the mat}
134 % }
135 % }
136 %}
137 %\end{verbatim}&
138 %\psset{treesep=2ex}
139 %\CLAUSE{
140 % \CORE{
141 % \OPR{2}{the}
142 % \ARG{\WORD(NP){cat}}
143 % \NUC{walked}
144 % \AAJ{\FanEnd{PP}{to the mat}}
145 % }
146 %}~~~
147 %&
148 %\small\bfseries
149 %\psset{treesep=2ex,levelsep=3em}
150 %~~~\CLAUSE{
151 % \CORE{
152 % \OPR{2}{the}
153 % \ARG{\WORD(NP){cat}}
154 % \NUC{walked}
155 % \AAJ{\FanEnd{PP}{to the mat}}
156 % }
157 %}
158 %\\
159 %\end{tabular}
160 %\end{center}
161 %The commands \verb+\WORD+ and \verb+\NUC+ may optionally be followed by an
162 %operator projection (see section~\ref{OP}), \verb+\FanEnd+ may not.
163 %\verb+\NUC+ also has an optional argument
164 %which allows the user to specify
165 %non-verb predicating elements, e.g.~\verb+\NUC[ADJ]{green}+. \verb+\OPR+
166 %is used to make operators, which have no drawn link to the layered
167 %structure. It takes two required arguments --- the number of levels/layers
168 %that should be skipped and the word itself --- and an optional argument
169 %which is a node name. See section~\ref{OP} for further details.
170 %
171 %\verb+\FanEnd+ and \verb+\CORE+ type commands accept an optional argument that
172 %specifies the node name for the \Core\ label. In the case of
173 %\verb+\FanEnd+, this label applies to the text at the top of the triangle.
174 %Other commands that behave in a similar manner to
175 %\verb+\CORE+ are: \verb+\SENTENCE+, \verb+\CLAUSE+, \verb+\PP+,
176 %\verb+\NP+, \verb+\NCORE+, and \verb+\NNUC+.
177 %
178 %By some devious trickery, \verb+\FanEnd+ may (in addition to the label) have
179 %either two or three arguments. If two arguments are given, as in the
180 %example, the the triangle or fan goes one level deep. If three arguments
181 %are given, then the first argument specifies how many levels deep the fan
182 %should be. I.e either \{top\}\{text\} or \{levels\}\{top\}\{text\} may be
183 %specified.
184 %If for some reason fine adjustments are needed to make the text
185 %marking the fan line up with the rest of the sentence, the macro
186 %\verb+\rrgfantweak+ may be altered from the default of -1pt.
187 %
188 %\subsection{Periphery and Complementisers}
189 %A periphery element may be added using any of four commands, depending on which
190 %side (left or right) it is of the relevant core it is to modify,
191 %and whether the
192 %label `\Periphery' should be positioned at a set distance
193 %from the core or whether it should be positioned normally above its
194 %decendant nodes.
195 %
196 %The `fixed offset' commands are \verb+\LPERIPH+ and \verb+\RPERIPH+, the
197 %`right angle' commands \verb+\lPERIPH+, \verb+\rPERIPH+, for left and
198 %right respectively.
199 %
200 %The right angle commands take three required arguments: the number of
201 %levels/layers to skip, the label for the upper node, and a tree.
202 %The fixed distance commands have an additional argument specifying
203 %the distance from the modified core. All periphery aelements may have an
204 %optional argument to specify the core to which they should apply. If this is
205 %used, then the relevant core should be labeled also, but with a prepended
206 %`CORE', as in the example below.
207 %Often it is more pleasing to have the periphery decended from an upper
208 %invisible node (created by \verb+\TOP+) than to have it distort the tree to
209 %which it logically belongs.
210 %
211 %\begin{tabular}{p{0.5\textwidth}c}
212 %\begin{verbatim}
213 %\psset{treesep=2ex}
214 %\TOP{
215 % \OPR{4}{the}
216 % \CLAUSE{
217 % \CORE[COREa]{
218 % \ARG{\WORD(NP){cat}}
219 % \NUC{walked}
220 % \AAJ{\FanEnd{PP}{to the mat}}
221 % }
222 % \rPERIPH[a]{2}{PP}{\WORD{on the floor}}
223 % }
224 %}
225 %\dolinks
226 %\end{verbatim}
227 %&
228 %\psset{treesep=2ex}
229 %\TOP{
230 % \OPR{4}{the}
231 % \CLAUSE{
232 % \CORE[COREa]{
233 % \ARG{\WORD(NP){cat}}
234 % \NUC{walked}
235 % \AAJ{\FanEnd{PP}{to the mat}}
236 % }
237 % }
238 % \rPERIPH[a]{3}{PP}{\WORD{on the floor}}
239 %}
240 %\dolinks
241 %\\
242 %\end{tabular}
243 %
244 %Complementisers (or clause linkage markers) are basicly of the same form as
245 %the periphery command, except they do not have a tree argument. On the
246 %assumption that these usually come before the linked element, there is also
247 %a short form: \verb+\CMPL+. which is the same as \verb+\lCMPL+. If a
248 %[label] argument is given, this should be the exact label of the core or
249 %clause node which the \verb+\CMPL+ modifies. The default is to label the
250 %item \CMPLtext, but changing \verb+\CMPLtext+ will have immediate effect.
251 %
252 %Note that the final command in the example is \verb+\dolinks+. This command
253 %draws the parts of any periphery and complementisers that were not drawn by
254 %the commands themselves. It should come after all linked nodes have been
255 %defined but before the next page break.
256 %\subsection{Tree Labeling Commands}
257 %The following table gives the commands that are used in labeling the tree,
258 %with their default definitions and result. The commands may of course be
259 %used in the main text and redefined as necessary.:
260 %\begin{center}
261 %\begin{tabular}{lll}
262 %\verb+\Sentence+&\verb+{\scshape Sentence}+&\Sentence\\
263 %\verb+\Clause+&\verb+{\scshape Clause}+&\Clause\\
264 %\verb+\Core+&\verb+{\scshape Core}+&\Core\\
265 %\verb+\Conj+&\verb+{\scshape Conj}+&\Conj\\
266 %\verb+\CMPLtext+&\verb+{\scshape cmpl}+&\CMPLtext\\
267 %\verb+\Nuc+&\verb+{\scshape Nuc}+&\Nuc\\
268 %\verb+\Arg+&\verb+{\scshape Arg}+&\Arg\\
269 %\verb+\aaj+&\verb+{\scshape AAJ}+&\aaj\\
270 %\verb+\pp+&\verb+{\scshape PP}+&\pp\\
271 %\verb+\np+&\verb+{\scshape NP}+&\np\\
272 %\verb+\Periphery+&\verb+{\scshape Periphery}+&\Periphery\\
273 %\end{tabular}
274 %\end{center}
275 %\subsection{The Operator Projection}\label{OP}
276 %The RRG projection decends below the text line. In this package there are
277 %three main commands concerned with the operator projection: \verb+\OP+,
278 %\verb+\OPJoin+ and \verb+\LINK+ (which also has variants \verb+\LLINK+,
279 %\verb+\RLINK+, \verb+\lLINK+ and \verb+\rLINK+, corresponding to the
280 %\verb+\CMPL+ commands). \verb+\OP+
281 %is used to draw (and label) the operator layers below verbs and nouns;
282 %\verb+\OPJoin+ is used in complex sentences to join two such stacks
283 %together and start a new stack of operator layers (positioned half-way
284 %between the two); and
285 %\verb+\LINK+ draws perpendicular links from operators to these layers,
286 %labeling them as specified. As expected, \verb+\LLINK+ and \verb+\RLINK+
287 %place their text a specified distance from the node in the tree to which
288 %they join.
289 %
290 %Due to the way that the \package{pst-tree} commands work, \verb+\OPJoin+
291 %cannot be used within any tree structure, and also it has not been possible
292 %thus far to automatically add to the height of the picture in an accurate
293 %manner. Thus some calculation is needed to account for extra depth of the
294 %structure that \verb+\OPJoin+ adds. The extra height it is necessary to
295 %allow for at the bottom of the figure is ((2$+$operator levels in this
296 %stack) $-$ Maximum number of operators in other stacks)$\times$\verb+\rrgoprsep+.
297 %
298 %In the case that an operator should decend from only part of a word (e.g.
299 %an affix) or from a non-word position (e.g. the beginning or end of the text),
300 %the \textsf{pst-node} commands \verb+\pnode+ and \verb+\Rnode+.
301 %should be used. The following example and the
302 %table of arguments in the section~\ref{toa} should make things clearer.
303 %\begin{verbatim}
304 %\begin{center}
305 %\psset{treesep=2ex}
306 %\TOP{
307 %\OPR[DEFa]{5}{the}
308 %\CLAUSE{
309 % \CORE{
310 % \CORE[COREa]{
311 % \ARG{
312 % \NP{
313 % \WORD{cat}{
314 % \OP{N}{\OP{\Nuc\subN}{\OP{\Core\subN}{\OP[cat]{\np}}}}
315 % }
316 % }
317 % }
318 % \LINK{DEFa}{cat}{DEF}
319 % \OPR[might]{2}{\pnode{IF}might}
320 % \OPR[not]{2}{not}
321 % \NUC{forget}{\OP{V}{\OP{\Nuc}{\OP[forgetcore]{\Core}}}}
322 % }
323 % \CMPL[COREb]{3}{to}
324 % \CORE[COREb]{
325 % \NUC{eat}{\OP{V}{\OP{\Nuc}{\OP[eatcore]{\Core}}}}
326 % \OPR[DEFb]{2}{the}
327 % \ARG{
328 % \NP{
329 % \WORD{rat}{
330 % \OP{N}{\OP{\Nuc\subN}{\OP{\Core\subN}{\OP[rat]{\np}}}}
331 % }
332 % \LINK{DEFb}{rat}{DEF}
333 % }
334 % }
335 % }
336 % }
337 %}
338 %\rPERIPH{4}{ADV}{\WORD{tomorrow}}
339 %}
340 %\OPJoin{forgetcore}{eatcore}{\OP[a]{\Core}{
341 % \OP[b]{\Clause}{\OP[c]{\Clause}{\OP[d]{\Clause}}}}}
342 %\LINK{might}{b}{MOD}
343 %\LINK{not}{a}{NEG}
344 %\LLINK{8em}{IF}{d}{IF}
345 %\LINK{IF}{c}{TNS}
346 %\dolinks
347 %\vspace{6\rrgoprsep}
348 %\end{center}
349 %\end{verbatim}
350 %
351 %\begin{center}
352 %\psset{treesep=2ex}
353 %\TOP{
354 %\OPR[DEFa]{5}{the}
355 %\CLAUSE{
356 % \CORE{
357 % \CORE[COREa]{
358 % \ARG{
359 % \NP{
360 % \WORD{cat}{
361 % \OP{N}{\OP{\Nuc\subN}{\OP{\Core\subN}{\OP[cat]{\np}}}}
362 % }
363 % }
364 % }
365 % \LINK{DEFa}{cat}{DEF}
366 % \OPR[might]{2}{\pnode{IF}might}
367 % \OPR[not]{2}{not}
368 % \NUC{forget}{\OP{V}{\OP{\Nuc}{\OP[forgetcore]{\Core}}}}
369 % }
370 % \CMPL[COREb]{3}{to}
371 % \CORE[COREb]{
372 % \NUC{eat}{\OP{V}{\OP{\Nuc}{\OP[eatcore]{\Core}}}}
373 % \OPR[DEFb]{2}{the}
374 % \ARG{
375 % \NP{
376 % \WORD{rat}{
377 % \OP{N}{\OP{\Nuc\subN}{\OP{\Core\subN}{\OP[rat]{\np}}}}
378 % }
379 % \LINK{DEFb}{rat}{DEF}
380 % }
381 % }
382 % }
383 % }
384 %}
385 %\rPERIPH{4}{ADV}{\WORD{tomorrow}}
386 %}
387 %\OPJoin{forgetcore}{eatcore}{\OP{\Core}{\OP[a]{\Clause}{\OP[b]{\Clause}{\OP[c]{\Clause}{\OP[d]{\Clause}}}}}}
388 %\LINK{might}{b}{MOD}
389 %\LINK{not}{a}{NEG}
390 %\LLINK{8em}{IF}{d}{IF}
391 %\LINK{IF}{c}{TNS}
392 %\dolinks
393 %\vspace{6\rrgoprsep}
394 %\end{center}
395 %
396 %\section{Tree-Building Commands and Arguments}
397 %In the table below, items in italic and their delimiters are optional.
398 %Where an argument is labeled ``tree'', that argument may be filled with one
399 %or more of the commands below, though some obviously make more sence than
400 %others. An argument labeled ``word'' or ``text'' is anything that
401 %should appear in the tree, the only difference between the
402 %arguments, is that ``text'' arguments are intended to be the text of the
403 %analysed sentence, and ``word'' arguments label different parts of the tree
404 %structure. Arguments labeled ``name'' are node names, which may be used for
405 %drawing lines to and from by various commands.
406 %\label{toa}
407 %\begin{center}
408 %\begin{tabular}{llp{0.35\textwidth}cc}
409 %\textbf{Command} & \textbf{Arguments} &\textbf{Summary} &
410 %\textbf{Item} & \textbf{Default}\\
411 %&&&\textbf{Named}& \textbf{Name}\\
412 %\verb+\TOP+ & \{tree\} &Makes (zero sized) logical tree, but top node and
413 %lines are not drawn. & \\
414 %\verb+\SENTENCE+ & [\emph{name}]\{tree\} & New layer of structure &
415 %Top&\textsf{SEN}
416 %\\
417 %\verb+\CLAUSE+ & [\emph{name}]\{tree\} &New layer of structure &
418 %Top&\textsf{CLS}\\
419 %\verb+\CORE+ & [\emph{name}]\{tree\} &New layer of structure &
420 %Top&\textsf{CORE}\\
421 %\verb+\ARG+ & [\emph{name}]\{tree\} &New layer of structure &
422 %Top&\textsf{arg}\\
423 %\verb+\AAJ+ & [\emph{name}]\{tree\} &New layer of structure &
424 %Top&\textsf{aaj}\\
425 %\verb+\PP+ & [\emph{name}]\{tree\} &New layer of structure & Top&\textsf{PP}\\
426 %\verb+\NP+ & [\emph{name}]\{tree\} &New layer of structure & Top&\textsf{NP}\\
427 %\verb+\NCORE+ & [\emph{name}]\{tree\} &New layer of structure &
428 %Top&\textsf{NC}\\
429 %\verb+\NNUC+ & [\emph{name}]\{tree\} &New layer of structure &
430 %Top&\textsf{NN}\\
431 %\verb+\OPR+ & [\emph{name}]\{num\}\{text\} &Entry \textbf{num} levels below
432 %current node & Text&\textsf{opr}\\
433 %\verb+\FanEnd+ & [\emph{name}]\{\emph{num}\}\{word\}\{text\} & Triangle/Fan
434 %(i.e. unanalysed) entry below current node, with the apex marked with the
435 %word argument. & Top&\textsf{fan}\\
436 %\verb+\End+ & [\emph{name}]\{text\}\{\emph{tree}\}& Obsolete simpler
437 %version of \verb+\WORD+ & Text & \textsf{x} \\
438 %\verb+\WORD+ & [\emph{name}](\emph{word})\{text\}\emph{\{tree\}} &Creates one or
439 %two level entry below current node.& Text&\textsf{x}\\
440 %\verb+\NUC+ & [\emph{word}]\{text\}\emph{\{tree\}}& Predicating Nucleus &\\
441 %\verb+\OP+ & [\emph{name}]\{word\}\emph{\{tree\}}& Operator projection
442 %layer & Text&\textsf{op}\\
443 %\end{tabular}
444 %\end{center}
445 %\section{Line Drawing Commands}
446 %\begin{center}
447 %\begin{tabular}{llp{0.45\textwidth}}
448 %\textbf{Command} & \textbf{Arguments} &\textbf{Summary} \\
449 %\verb+\CMPL+ &[\emph{name}]\{num\}\{text\} & Also \verb+\rCMPL+. Links to
450 %the object named (default: \textsf{CLAUSE}) with right-angle connections.\\
451 %\verb+\LCMPL+ &[\emph{name}]\{length\}\{num\}\{text\} & Also \verb+\RCMPL+.
452 %Links to the object named (default: \textsf{CLAUSE}) with \CMPLtext\
453 %centered \textsf{length} from
454 %target.\\
455 %\verb+\lPERIPH+ &[\emph{Extn}]\{num\}\{word\}\{\emph{tree}\} & Also
456 %\verb+\rPERIPH+. Links to the object named \hfil\penalty0\hbox{``COREExtn''} with
457 %right-angle connections.\\
458 %\verb+\LPERIPH+ &[\emph{Extn}]\{length\}\{num\}\{word\}\{\emph{tree}\}
459 %& Also \verb+\RPERIPH+. Links to the object named \hfil\penalty0\hbox{``COREExtn''} with
460 %\Periphery\ centered \textsf{length} from target.\\
461 %\verb+\lLINK+ &[\emph{extra}]\{name\}\{name\}\{word\}
462 %& Also \verb+\rLINK+. Links two named objects with
463 %right-angle connections.\\
464 %\verb+\LLINK+ &[\emph{extra}]\{length\}\{name\}\{name\}\{word\}
465 %& Also \verb+\RLINK+. Links two named objects with
466 %\textsf{text} centered \textsf{length} from target.\\
467 %\end{tabular}
468 %\end{center}
469 %In the above table the parameter named \emph{extra} is appended to the
470 %optional argument of a \verb+\ncdiag+ or \verb+\ncangle+ command. It may be
471 %used for forcing certain unusual drawing styles, but is best ignored. If
472 %used it must start with a comma.
473 %\section{Misc. Commands}
474 %\subsection{Logical Structures}
475 %\begin{tabular}{lll}
476 %\textbf{Command} & \textbf{Result} & \textbf{Description} \\
477 %\verb+\pred{greet}+&\pred{greet} & Predicate in logical structure \\
478 %\verb+\prddo+ & \prddo & Shorthand for \verb+\pred{do}+ \\
479 %\verb+\prdDO+ & \prdDO & Shorthand for \verb+\pred{DO}+ \\
480 %\verb+\SEML+&\SEML&Shorthand for \verb+{\textsf{SEML}\,}+\\
481 %\verb+\INGR+&\INGR&Shorthand for \verb+{\textsf{INGR}\,}+\\
482 %\verb+\BECOME+&\BECOME&Shorthand for \verb+{\textsf{BECOME}\,}+\\
483 %\verb+\CAUSE+&\CAUSE&Shorthand for \verb+{\textsf{CAUSE}\,}+\\
484 %\verb+\NOT+&\NOT&Shorthand for \verb+{\textsf{NOT}\,}+\\
485 %\end{tabular}
486 %\subsection{Other Commands and Lengths}
487 %\begin{tabular}{llp{0.65\textwidth}}
488 %\verb+\textsubscript{}+ & Macro& Subscript equivalent for
489 %\verb+textsuperscript+ command that is unaccountably missing from
490 %latex.ltx\\
491 %\verb+\sup{}+ & Macro & Shorthand for \verb+\textsuperscript+ \\
492 %\verb+\sub{}+ & Macro & Shorthand for \verb+\textsubscript+ \\
493 %\verb+\subN+& Macro & Shorthand for \verb+\textsubscript{\scshape{n}}+, for
494 %labeling\vfill e.g.\ \Core\subN\ (typed: \verb+\Core\subN+)\\
495 %\verb+\rrgoprsep+ & Length & Separation between levels on operator
496 %projection (default is 1.5em)\\
497 %\verb+\rrgfantweak+ & Macro & Fine adjustment of fan (triangle) height.
498 %(default -1pt)\\
499 %\verb+\dolinks+& Macro&Necessary to actually draw and label lines for
500 %periphery and complementiser commands. \\
501 %\end{tabular}
502 % \iffalse meta-comment
503 % \fi
504 %\section{The code itself}
505 %\MakeShortVerb{\|}
506 % \iffalse meta-comment
507 %<*package>
508 % \fi
509 % \begin{macrocode}
510 \ProvidesPackage{rrgtrees}[2004/11/14 RRG tree drawing]
511 \RequirePackage{pst-node,pst-tree}
512 % \end{macrocode}
513 %\subsection{Logical structures}
514 % Before we start with the tree commands proper, we'll use some shortcuts for
515 % writing logical structures\ldots
516 % \begin{macrocode}
517 \newcommand{\pred}[2][]{\textbf{#2}\ensuremath{'_{#1}}}
518 \newcommand\SEML{\textsf{SEML}\,}
519 \newcommand\INGR{\textsf{INGR}\,}
520 \newcommand\BECOME{\textsf{BECOME}\,}
521 \newcommand\CAUSE{\textsf{CAUSE}\,}
522 \newcommand\NOT{\textsf{NOT}\,}
523 \newcommand\prddo{\pred{do}}
524 \newcommand\prdDO{\pred{DO}}
525 % \end{macrocode}
526 %
527 % \ldots\ and some tree entries that we want to be consistent
528 %
529 % \begin{macrocode}
530 \def\Sentence{{\scshape Sentence}}
531 \def\Clause{{\scshape Clause}}
532 \def\Core{{\scshape Core}}
533 \def\Conj{{\scshape Conj}}
534 \def\CMPLtext{{\scshape cmpl}}
535 \def\Nuc{{\scshape Nuc}}
536 \def\Arg{{\scshape Arg}}
537 \def\aaj{{\scshape AAJ}}
538 \def\pp{{\scshape PP}}
539 \def\np{{\scshape NP}}
540 \def\Periphery{{\scshape Periphery}}
541 % \end{macrocode}
542 %\subsection{Initial setup}
543 %We'll now define a few lengths and sane defaults that will be
544 %needed later.
545 % \begin{macrocode}
546 \newlength\rrgoprsep
547 \newlength\rrg@tmpdim
548 \newlength\rrg@tmpdima
549 \newlength\rrg@tmpdimb
550 \setlength{\rrgoprsep}{1.5em}
551 % \end{macrocode}
552 %
553 %\subsection{Generic versions of commands and internally used bits.}
554 %
555 % \begin{macrocode}
556 \def\rrg@empty@toks{\global\let\rrg@dolinks\@empty}
557 \rrg@empty@toks
558 % \end{macrocode}
559 %The |\dolinks| is used to draw things that can only be done once the rest
560 %of the tree is defined. Tokens to be executed are deferred into a
561 %collecting point by many commands and the macro executes the
562 %tokens in the internal collection, and
563 %then resets the token list for the next tree.
564 % \begin{macrocode}
565 \def\dolinks{\rrg@dolinks\rrg@empty@toks}
566 \def\@once@tmp{}
567 \def\rrg@addlinks{\g@addto@macro\rrg@dolinks}
568 \newcommand{\rrg@newnode}[1]{\@namedef{rrg@node@#1}{\null}}
569 % \end{macrocode}
570 %
571 % If this had worked, it would have automatically and drawn the line if
572 % possible, or added a delay otherwise. It would have been nicer,
573 % but it didn't work.
574 % Dunno why.
575 %
576 % \begin{macrocode}
577 %%Broken code:
578 %%\newcommand{\rrg@do@or@add@link}[3]{\@ifundefined{rrg@node@#1}{\typeout{#1
579 %% undefined}\rrg@addlinks{#3}}{\@ifundefined{rrg@node@#2}
580 %% {\typeout{#2 undefined}\rrg@addlinks{#3}}{#3}}}
581 % \end{macrocode}
582
583 %
584 %This combines an arbitary level skip, with a right angled join, as used in
585 %periphery and clause link marker elements.
586 %
587 %Parameters:
588 % \#1 = Pre-skip;
589 % \#2 = Name of top node;
590 % \#3 = Name of link-to node;
591 % \#4 = Text of top node;
592 % \#5 = Lower tree;
593 % \#6 = Mark at Right angle;
594 % \#7 = Join angle at link-to node.
595 %
596 % \begin{macrocode}
597 \newcommand{\rightangle@link}[7]{
598 \settowidth{\rrg@tmpdim}{#4}%
599 \skiplevels{#1}%
600 \rrg@newnode{#2}%
601 \ifdim\rrg@tmpdim>0pt
602 \pstree{\TR[edge=none, name=#2]{#4}}{%
603 #5}%
604 \else%
605 \TR[edge=none,name=#2]{#5}%
606 \fi%
607 \endskiplevels%
608 \rrg@addlinks{\ncangle[angleA=90,angleB=#7,armB=0]{->}{#2}{#3}%
609 \ncput*[npos=1]{#6}}}
610 % \end{macrocode}
611
612 % This version produces a diagonal link for close spacing or
613 % line-crossing periphery (etc) elements.
614 % \begin{macrocode}
615 \newcommand{\diag@link}[8]{
616 \settowidth{\rrg@tmpdim}{#4}%
617 \expandafter\typeout{\the\rrg@tmpdim}
618 \skiplevels{#1}%
619 \rrg@newnode{#2}%
620 \ifdim\rrg@tmpdim>0pt
621 \pstree{\TR[edge=none, name=#2]{#4}}{%
622 #5}%
623 \else%
624 \typeout{#4:#5}%
625 \TR[edge=none,name=#2]{#5}%
626 \fi%
627 \endskiplevels%
628 \rrg@addlinks{\ncdiagg[angleA=#7,armA=#8]{<-}{#3}{#2}%
629 \ncput*[npos=1]{#6}}}
630 % \end{macrocode}
631 % Different versions of predicating nucleus, depending on presence of an
632 % operator projection
633 % \begin{macrocode}
634 \newcommand{\@NUCa}[3]{\pstree{\TR{\@do@once\Nuc}}{
635 \pstree{\TR{#1}}{\pstree{\TR[name=verb]{\ncput*[npos=1.5]{\scshape{Pred}}#2}}{#3}}}}
636 \newcommand{\@NUCn}[2]{\pstree{\TR{\@do@once\Nuc}}{\pstree{\TR{#1}}%
637 {\TR[name=verb]{\ncput*[npos=1.5]{\scshape{Pred}}#2}}}}
638 % \end{macrocode}
639
640 %\subsection{User commands for periphery, etc.}
641 % \begin{macrocode}
642 \newcommand{\CMPL}[3][CLAUSE]{\rightangle@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{180}}
643 \newcommand{\lCMPL}{\CMPL}
644 \newcommand{\rCMPL}[3][CLAUSE]{\rightangle@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{0}}
645 \newcommand{\LCMPL}[4][CLAUSE]{\diag@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{180}{#4}}
646 \newcommand{\RCMPL}[4][CLAUSE]{\diag@link{#2}{CMPL#1}{#1}{}{#3}{\CMPLtext}{0}{#4}}
647 \newcommand{\lPERIPH}[4][]{\rightangle@link{#2}{PERIPH#1}{CORE#1}%
648 {#3}{#4}{\Periphery}{180}}
649 \newcommand{\rPERIPH}[4][]{\rightangle@link{#2}{PERIPH#1}{CORE#1}%
650 {#3}{#4}{\Periphery}{0}}
651 \newcommand{\LPERIPH}[5][]{\diag@link{#2}{PERIPH#1}{CORE#1}{#3}%
652 {#4}{\Periphery}{180}{#5}}
653 \newcommand{\RPERIPH}[5][]{\diag@link{#2}{PERIPH#1}{CORE#1}{#3}%
654 {#4}{\Periphery}{0}[#5]}
655 % \end{macrocode}
656
657
658 %\subsection{Predicating Nucleus}
659 % \begin{macrocode}
660 \newcommand{\NUC}[2][V]{\@ifnextchar\bgroup{\@NUCa{#1}{#2}}{\@NUCn{#1}{#2}}}
661 % \end{macrocode}
662 %
663 %\subsection{More normal tree parts}
664 %\subsubsection{Basic components}
665 % \begin{macrocode}
666 \newcommand{\TOP}[1]{\pstree[thislevelsep=0pt,linestyle=none]{\Tn}%
667 {\psset{linestyle=solid}#1}}
668 \newcommand{\SENTENCE}[2][SEN]{\pstree{\TR[name=#1]{\Sentence}\@do@once}{#2}}
669 \newcommand{\CLAUSE}[2][CLS]{\pstree{\TR[name=#1]{\Clause}\@do@once}{#2}}
670 \newcommand{\CORE}[2][CORE]{\pstree{\TR[name=#1]{\Core}\@do@once}{#2}}
671 \newcommand{\ARG}[2][arg]{\pstree{\TR[name=#1]{\Arg}\@do@once}{#2}}
672 \newcommand{\AAJ}[2][aaj]{\pstree{\TR[name=#1]{\aaj}\@do@once}{#2}}
673 \newcommand{\PP}[2][PP]{\pstree{\TR[name=#1]{\pp}\@do@once}{#2}}
674 \newcommand{\NP}[2][NP]{\pstree{\TR[name=#1]{\np}\@do@once}{#2}}
675 \newcommand{\NCORE}[2][NC]{\pstree{\TR[name=#1]{\Core\subN}\@do@once}{#2}}
676 \newcommand{\NNUC}[2][NN]{\pstree{\TR[name=#1]{\Nuc\subN}\@do@once}{#2}}
677 % \end{macrocode}
678 %\subsubsection{Word node}
679 %% |\WORD| tries to be flexible in the arguments it gets.
680 %% The user may optionally include the (part of speach) a |[name]| for the
681 %% |{word}| node, and possibly being followed by an |{operator projection}|.
682 %% E.g. |\WORD{hello}|, |\WORD[hi]{hello}|, |\WORD(N){cat}|,
683 %% |\WORD(N)[pussy]{cat}|
684 %% are all permitted, as is any of the above with an operator projection
685 % \begin{macrocode}
686 \newcommand{\WORD}{\let\@word@tmp=\empty\@ifnextchar(%) bracket match
687 {\@word@ii}{\@word@i}}
688 \newcommand{\@word@i}[2][x]{\@end{#1}{#2}} % Nice easy single level word
689 \def\@word@ii(#1){\@ifnextchar[%] bracket match % we have a fuller tree.
690 {\@word@iii{#1}}{\@word@iii{#1}[x]}}
691 % Here goes!
692 \def\@word@iii#1[#2]#3{\@ifnextchar\bgroup% operators follow
693 {\@word@iv{#1}{#2}{#3}}{\pstree{\TR{#1}\@do@once}{\TR[name=#2]{#3}}}}
694
695 \newcommand{\@word@iv}[4]{\pstree{\TR{#1}\@do@once}{\pstree{\TR[name=#2]{#3}}{#4}}}
696 % \end{macrocode}
697 %
698 % |\@do@once| does the delayed linestyle reset required by someone using
699 % |\UNJOINED|
700 % \begin{macrocode}
701 \newcommand{\@do@once}{\@once@tmp\def\@once@tmp{}}
702 \newcommand{\UNJOINED}{\def\@once@tmp{\global\let\psedge\@save@edge}%
703 \let\@save@edge\psedge\def\psedge##1##2{}}
704 % \end{macrocode}
705 %\subsubsection{Operator node}
706 %|\OPR| is used for marking the supplied word as an operator. It has no
707 %representation in the upper tree but is described as though it were part
708 %of it. The optional firse parameter is its tag label (for drawing linking
709 %lines, the second defines the number of logical levels to skip, which is a
710 %function of the node placement.
711 % \begin{macrocode}
712 \newcommand{\OPR}[3][opr]{\skiplevels{#2}{\TR[edge=none,name=#1]{#3}}\endskiplevels}
713 % \end{macrocode}
714 %\subsection{Operator tree and linking}
715 % |\OP| defines items in the operator projection.
716 % \begin{macrocode}
717 \newcommand\OP[2][op]{\psset{levelsep=\rrgoprsep}\@end{#1}{\@do@once#2}}
718 \newcommand{\oprlink}[4]{%
719 \ncput*[npos=1 #1]{\rnode{label}{#4}}%
720 \ncline[linestyle=dashed]{#2}{label}\ncline{->}{label}{#3}%
721 }
722 \newcommand{\LLINK}[5][]{%
723 \ncdiagg[linestyle=none,angleA=180,armA=#2]{#4}{#3}%
724 \oprlink{#1}{#3}{#4}{#5}
725 }
726 \newcommand{\RLINK}[5][]{%
727 \ncdiagg[linestyle=none,angleA=0,armA=#2]{<-}{#4}{#3}%
728 \oprlink{#1}{#3}{#4}{#5}
729 }
730 \newcommand{\rLINK}[4][]{\ncangle[linestyle=none,angleA=-90,angleB=0 #1]{#2}{#3}%
731 \oprlink{}{#2}{#3}{#4}
732 }
733 \newcommand{\LINK}[4][]{\ncangle[linestyle=none,angleA=-90,angleB=180 #1]{#2}{#3}%
734 \oprlink{}{#2}{#3}{#4}
735 }
736 \newcommand{\lLINK}{\LINK}
737 % \end{macrocode}
738 % The |\End| command is just a simple terminal node, which may have an
739 % operator tree following it..
740 % \begin{macrocode}
741 \newcommand{\End}[2][x]{\@end{#1}{#2}}
742 % \end{macrocode}
743 %
744 % First attempt at clever operators. It might even work one day.
745 %
746 % \begin{macrocode}
747 %\newcommand\Ende{\@ifnextchar[%]
748 %{\@Ende}{\@Ende[x]}}
749 %
750 %\def\@Ende[#1]#2{\def\@End{\TR[name=#1]{#2}}%
751 %\typeout{@Ende}
752 %\@check@Ende}
753 %
754 %\def\@check@Ende{\@ifnextchar(% ] bracket matching
755 %{\typeout{Brkt}}{\typeout{No Brkt}}
756 %\@End}%
757 %
758 %\def\@check@OP{%
759 %\typeout{\@End}
760 %\@ifnextchar[% ] bracket matching
761 %{\@OP}{\@ifnextchar<% > bracket matching
762 %{\@OP[x]}{}}%
763 %}
764 %\def\@OP[#1]<#2>{\typeout{OP}\def\@Tmp{\expandafter\pstree{\TR[name=#1]{#2}}%
765 %{\@End}}\let\@End=\@Tmp}
766 % \end{macrocode}
767
768 %
769 % The |\@end| command is run by all things that could be followed by optional
770 % decendents. Optional parts are enclosed in \{\}, just like a normal arg.
771 % The reason for this is so that the user dosn't need to define the
772 % tree in some horrible inverted order, or remember a whole different set
773 % of commands.
774 %
775 % \begin{macrocode}
776 \newcommand{\@end}[2]{\@ifnextchar\bgroup% matching
777 {\@are@ops{#1}{#2}}{\@end@{#1}{#2}}}
778 \newcommand{\@end@}[2]{\TR[name=#1]{#2}}
779 \def\@are@ops#1#2#3{\pstree{\@end@{#1}{#2}}{#3}}
780 % \end{macrocode}
781 %\subsection{Macros for fans/triangles}
782 % Adjustment in position of fan label due to height of line or something similar.
783 %
784 % \begin{macrocode}
785 \def\rrgfantweak{-1pt}
786 % \end{macrocode}
787 %
788 % Draw a fan, but first find out how many arguments we have. I.e. we allow
789 % |\FanEnd{depth}{head}{text}| or
790 % |\FanEnd{head}{text}|
791 % plus an optional [label] for the head.
792 %
793 % \begin{macrocode}
794 \newcommand{\FanEnd}[3][fan]{%
795 \@ifnextchar\bgroup{\@fanend{#1}{#2}{#3}}{\@@fanend{#1}{1}{#2}{#3}}}
796 \def\@fanend#1#2#3#4{\@@fanend{#1}{#2}{#3}{#4}}
797 \newcommand{\@@fanend}[4]{
798 \setbox\@tempboxa\hbox{#4}%
799 \setlength{\rrg@tmpdim}{\wd\@tempboxa}%
800 \addtolength{\rrg@tmpdim}{-1ex}%
801 \setlength{\rrg@tmpdimb}{\psk@levelsep}%
802 \setlength{\rrg@tmpdima}{\psk@levelsep}%
803 \setlength{\rrg@tmpdimb}{#2\rrg@tmpdima}%
804 \addtolength{\rrg@tmpdimb}{+0.7ex}%
805 \addtolength{\rrg@tmpdimb}{-\ht\@tempboxa}%
806 \addtolength{\rrg@tmpdimb}{-\pslabelsep}%
807 \addtolength{\rrg@tmpdimb}{\rrgfantweak}%
808 \pstree[thislevelsep=\rrg@tmpdimb]{\TR{#3}}{\Tfan[fansize=\rrg@tmpdim]%
809 \nbput*[npos=1.5,name=#1]{#4}}
810 }
811 % \end{macrocode}
812 % \subsection{Final bits and pieces}
813 % This one should have been defined in latex.ltx
814 % \begin{macrocode}
815 \DeclareRobustCommand*\textsubscript[1]{%
816 \@textsubscript{\selectfont#1}}
817 \def\@textsubscript#1{%
818 {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
819 % \end{macrocode}
820 % Now I make some shortcuts, and use the |\textsubscript| command
821 % \begin{macrocode}
822 \newcommand{\spr}[1]{\textsuperscript{#1}}
823 \newcommand{\sub}[1]{\textsubscript{#1}}
824 \newcommand{\subN}{\textsubscript{\scshape{n}}}
825 % \end{macrocode}
826 %OPJoin is used to define a joined operator tree - see example in text.
827 %%Args for |\OPJoin| are:
828 %% [Offset from centre] \{node\} \{node\} \{Text/structure\}
829 % \begin{macrocode}
830 \newcommand{\OPJoin}[4][2\rrgoprsep]{\ncline[linestyle=none]{#2}{#3}%
831 \nbput[labelsep=#1,npos=0.5]{\Rnode{join-#2-#3}{#4}%
832 }\ncline[linestyle=solid]{#2}{join-#2-#3}%
833 \ncdiag[armA=0,armB=0]{#3}{join-#2-#3}}
834 % \end{macrocode}
835 % It could get very confusing if the user re-defines these.. curved trees,
836 % anyone?
837 % \begin{macrocode}
838 \def\psedge{\ncdiag}
839 \psset{levelsep=3.5em,nodesep=1pt,angleA=-90,angleB=90,armA=0,armB=0}
840 % \end{macrocode}
841 % \iffalse meta-comment
842 %</package>
843 % \fi