summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xyling/xyli-doc.tex
blob: 4721c505ffec6f6bb189687204240651f24a4917 (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
\documentclass[12pt,a4paper]{article}
\usepackage{avm}
\usepackage{xyling}
\usepackage{textcomp}
\usepackage{mflogo}
\usepackage{wasysym}


\setlength{\parindent}{0pt}
\setlength{\parskip}{1.5ex}

\title{\texttt{xyling} -- \LaTeX\ macros for linguistic graphics using the
  \texttt{xypic} module\\ version 1.1, July 31, 2006}

\author{Ralf Vogel\\Institut f\"ur Linguistik, Universit\"at Potsdam\\\tt
  rvogel@ling.uni-potsdam.de\\\tt http://www.ling.uni-potsdam.de/\~{}rvogel/xyling
} \date{December 31, 2004}
\frenchspacing\raggedbottom


\begin{document}\maketitle

This file explains the usage of the tree drawing macros in
\texttt{xyling.sty}. Please also inspect the style file which contains detailed
comments of the macros. These macros build on the \texttt{xypic} package by
Kristoffer H. Rose, version 3.7. 

\fbox{\parbox{.975\textwidth}{ \texttt{xypic} is loaded by \texttt{xyling.sty}
    with the \texttt{dvips} option in order to be able to produce coloured
    branches. This has a bad side effect: The use of the dvips option might
    cause branches to disappear when you produce a pdf file with
    \texttt{pdflatex}. Likewise, other packages that use postscript, like
    \texttt{pstricks}, might have such side effects. If you experience this,
    there are two ways of overcoming it:

\begin{enumerate}
\item erase the dvips option in the \texttt{xypic} call in line 57 of
  \texttt{xyling.sty}, i.e., use: \texttt{\textbackslash
    RequirePackage[color,all]\{xy\}}.  You will no longer be able to use
  coloured branches now, however. Similarly, you might have to avoid using
  other postscript packages, too.
 \item create the pdf file via dvips and ps2pdf conversion. This is how this
   documentation pdf file is created.
\end{enumerate} }}
 
Load \texttt{xyling} with \verb|\usepackage{xyling}|.

The macros in this package model the construction of syntactic tree structures
as a genuinely graphical problem: they contain three types of objects:

\begin{itemize}
\item the \emph{grid}
\item the \emph{node labels}
\item the \emph{branches}
\end{itemize}

The branches and nodes are positioned relative to the grid. It is
essential that each of these three elements is constructed independent of the
other two. They can be modified without unwanted side effects. This
is, to my mind, the most important difference to other tree drawing macro
packages, where, in particular, the label width often changes the angles of the
branches. 

A second major advantage to my mind lies in using the excellent \texttt{xypic}
package.  \texttt{xypic} generates \MF\ code, so the drawing of trees is not
dependent on postscript specials, as, e.g., in Wolfgang Sternefeld's
\texttt{ps-trees}. Hence, no postprocessing is required. The trees generated by
postscript specials can neither be seen in a dvi previewer (at least not in my
current version of \texttt{xdvi} for linux), nor can they be taken over into a
pdf file by \texttt{pdflatex} (but it works in dvi to pdf conversion with
\texttt{dvipdf}, or ps to pdf conversion with \texttt{ps2pdf}).


\section{The Grid}
\label{sec:grid}

A tree is a simple macro of the form \verb|\Tree{ ... }|. It is an \texttt{xymatrix}, with
\verb|&| as column separator and \verb|\\| as row separator. You should be
familiar with this structure from tabulars and similar structures.

\verb|\Tree| has an optional argument that can be used for changing the space
between columns. The default is 0, wich does not actually mean 0 space, but
rather the default space. A negative value makes the tree smaller, a positive
value makes it wider:

\begin{minipage}{.5\linewidth}
 \begin{tabular}{l@{~~=~~}l}
    \Tree{A & B} & \verb|\Tree{A & B}|\\
    \Tree[1]{A & B} & \verb|\Tree[1]{A & B}|\\
    \Tree[-1]{A & B} & \verb|\Tree[-1]{A & B}|
 \end{tabular}  
\end{minipage}


The distance between rows can also be controlled using the ``k''ontrolled version of
\verb|\Tree|, \verb|\Treek|, which has one more obligatory argument, the distance
between rows, which is defaulted to 2pc in \verb|\Tree|. Check the examples in table
\ref{tab:treek}.

 \begin{table}[htbp]
   \begin{center}
     \begin{tabular}{|l@{~~=~~}p{.5\linewidth}|}\hline
       \Tree{ & VP \\ V && NP } & \verb|\Tree{ & VP \\ Vzero && NP }|\\\hline
       \Treek{1}{ & VP \\ V && NP } & \verb|\Treek{1}{ & VP \\ V && NP }|\\\hline
       \Treek{3}{ & VP \\ V && NP } & \verb|\Treek{3}{ & VP \\ V && NP }|\\\hline
       \Treek{4}{ & VP \\ V && NP } & \verb|\Treek{4}{ & VP \\ V && NP }|\\\hline
     \end{tabular}\\\medskip
     \caption{Effects of the first argument of \textbackslash \texttt{Treek}}
     \label{tab:treek}
   \end{center}
 \end{table}
 \section{The Nodes}
 \label{sec:nodes}

A node is introduced with the command \verb|\K{...}|. Text is centered, both
horizontally and vertically! This means that text boxes might not be aligned on
the same baseline in \texttt{xypic}, using its standard command for text
insertion, \verb|\txt|. You can see this here:

\underline{\Tree{\txt{muss~~} \txt{musg~~} \txt{must~~} \txt{Muss~~} \txt{Musg~~}}}

The code:\\
\verb|\Tree{\txt{muss~~}| \verb|\txt{musg~~}| \verb|\txt{must~~}| \newline
\verb|\txt{Muss~~}| \verb|\txt{Musg~~}}| 

The command \verb|\K| contains a strut of 18pt to prevent this. This is perfect
for up to 12pt fonts:

\underline{\Tree{\K{muss~~} & \K{musg~~} & \K{must~~} &\K{Muss~~} & \K{Musg~~}}}

The code:\\ \verb|\Tree{\K{muss~~}&| \verb|\K{musg~~}&| \verb|\K{must~~}&|
  \verb|\K{Muss~~}&| \verb|\K{Musg~~}}| 

Node labels have the width 2pc, which is fine, because most node labels consist
of two upright letters, like NP, VP etc. Extremely wide labels do not affect the
matrix, because the node width is determined independently of the content of the
node -- by the value \verb|@W=2pc| in the definition of \verb|\Tree| and
\verb|\Treek|. 

\verb|\K| has an optional argument to move text freely horizontally -- measured
in pc. Positive values move the label to the right, negative values to the 
left. 1pc is about 0.5 em in a 12pt font. Horizontal adjustments are necessary
for wide nodes:

\Tree{
  & \K{VP}    \B{dl}\B{dr}    \\
  \K{\emph{very very very wide node}} & & \K{V$^0$} }

The code:\vspace{-2ex}
\begin{verbatim}
\Tree{                  & \K{VP}    \B{dl}\B{dr}    \\
  \K{\emph{very very very wide node}} & & \K{V$^0$}  }
\end{verbatim}

We have two solutions to this problem. The global one is widen the inter-column
space with the optional argument of \verb|\Tree|:

\Tree[1]{                               
                                    & \K{VP}  \B{dr}\B{dl} \\  
\K{\emph{very very very wide node}} &        & \K{V$^0$} \\
}

The code:\vspace{-2ex}
\begin{verbatim}
\Tree[1]{                         & \K{VP}  \B{dr}\B{dl} \\  
\K{\emph{very very very wide node}} &        & \K{V$^0$} }
\end{verbatim}

The second solution is moving the wide node a bit to the left, using the
optional argument of \verb|\K|:

 \Tree{
                                     & \K{VP}       \B{dl}\B{dr}  \\
 \K[-5]{\emph{very very very wide node}} &        & \K{V$^0$}  }

The code:\vspace{-2ex}
\begin{verbatim}
 \Tree{                         & \K{VP} \B{dr}\B{dl}  \\
 \K[-5]{\emph{very very very wide node}} & & \K{V$^0$}  }
\end{verbatim}

\verb|\Kk| offers full control over the vertical and horizontal dimension.  The
optional argument of \verb|\Kk| is the same as that of \verb|\K|, but there is
an additional obligatory argument denoting the vertical adjustment. So the
syntax is: \verb|\Kk[horizontal adjustment]{vertical adjustment}{node label}|.
The command \verb|\Kk[1]{1}{VP}| places the node VP 1pc right of and 1pc higher
than the standard position. This in fact allows you to put anything anywhere in
the tree.  You can add comments to the side of the tree etc. 

Often, especially in the terminal nodes, you might need more than one line of  
text. Use the command \verb|\Below| for putting text below text inserted by  
\verb|\K|. Check the following example:  

\begin{minipage}[t]{2cm}  
  \Tree{\K{NP}\B{d} \\ \K{the}\Below{little}\Below{dog}} 
\end{minipage} 
\begin{minipage}[t]{10cm} 
\begin{verbatim}   
\Tree{\K{NP}\B{d} \\    
\K{the}\Below{little}\Below{dog}}    \end{verbatim}   
\end{minipage}  

\verb|\Below|  has an optional argument for the vertical adjustment, negative  
value lowers the text, positive value raises it. There also exists a kontrolled 
version, \verb|Belowk|, which has the horizontal adjustment as its first  
obligatory argument in addition. 


\section{The Branches} 
\label{sec:branches} 

Branch commands are inserted in the same field as their dominating node. The 
simplest command is \verb|\B|. It has one obligatory argument, the description
of the target field. It is given in the steps it takes to reach it. For 
instance, \verb|\B{dl}| draws a branch to the field one step down and one step
left from the current field. Use \texttt{u} and \texttt{r} for upwards and 
rightwards steps. Upwards branches will strike through the label, however, so
this is not very useful. Branches should always go downwards. 
 
We are now ready to draw our first tree: 

\begin{center} \label{firsttree}
  \Tree{          & \K{VP}\B{dl}\B{dr} \\ 
    \K{NP}\B{d} &                  & \K{V$'$}\B{dl}\B{dr} \\ 
    \K{\emph{John}}& \K{V$^{0}$}\B{d} &   & \K{NP}\B{d}      \\ 
    & \K{\emph{loves}} & & \K{\emph{Mary}} } 
\end{center} 
This is the code:

\begin{verbatim}  
\Tree{          & \K{VP}\B{dl}\B{dr}                      \\  
    \K{NP}\B{d} &                  & \K{V$'$}\B{dl}\B{dr} \\ 
 \K{\emph{John}}& \K{V$^{0}$}\B{d} &   & \K{NP}\B{d}      \\ 
                & \K{\emph{loves}} &   &  \K{\emph{Mary}}   }\end{verbatim}  

\verb|\B| has an optional argument, the vertical adjustment of the starting  
position of the branch, negative value, e.g. \verb|\B[-1]{d}|, lowers the
starting position, positive value raises it.

Some grammar formalisms, require labels on branches -- like HPSG, where head
and complement are explicitly denoted with the labels $H$ and $C$. This is
quite easy to integrate. The command \verb|\B| is based on the \texttt{xypic}
command \verb|\ar| which has the option of putting a label on a line. It uses
the syntax of subscripting and superscripting, i.e., \verb|^{}| and
\verb|_{}|. If you put these commands right behind a branch command, you will
get labels on the branch, \verb|_{}| puts it on the branches left side, and
\verb|^{}| on its right. The label is written in math mode, i.e., slanted,
unless you specify it to be in normal text font with, e.g.
\verb|\textnormal{}|. Here comes an example:\footnote{Thanks to Doug Arnold
  for his suggestion to include this feature.}

\begin{center}
  \Tree{          & \K{VP}\B{dl}_{C}\B{dr}^{H}                      \\
    \K{NP}\B{d} &                  & \K{V$'$}\B{dl}_H\B{dr}^C \\
    \K{\emph{John}}& \K{V$^{0}$}\B{d} &   & \K{NP}\B{d}      \\
    & \K{\emph{loves}} & & \K{\emph{Mary}} }
            \end{center}
\begin{verbatim}
\Tree{          & \K{VP}\B{dl}_{C}\B{dr}^{H}               \\  
    \K{NP}\B{d} &               & \K{V$'$}\B{dl}_H\B{dr}^C \\ 
 \K{\emph{John}}& \K{V$^{0}$}\B{d} &   & \K{NP}\B{d}       \\ 
                & \K{\emph{loves}} &   &  \K{\emph{Mary}}   }
\end{verbatim}

There is no limitation on the number of branches either:

\Tree{    & \K{S} \B{dl}\B{d}\B{dr}\B{drr} \\
\K{NP}\B{d} & \K{V}\B{d} & \K{NP}\B{d} & \K{NP}\B{d} &     \\ 
      \K{John} & \K{gave} & \K{Mary} & \K[2]{cookies}  }
\begin{verbatim}
\Tree{      & \K{S} \B{dl}\B{d}\B{dr}\B{drr}             \\
\K{NP}\B{d} & \K{V}\B{d} & \K{NP}\B{d} & \K{NP}\B{d}     \\ 
   \K{John} & \K{gave}   & \K{Mary}    & \K[2]{cookies}  }
\end{verbatim}
    
HPSG is also famous for crossing branches in cases where the linear order
and the hierarchical structure do not match. You can, of course, also let
branches cross. There are no system specific limits to what kinds of trees
you might want to draw. An admittedly ugly looking example is the
following German object initial sentence:

\Tree[.5]{ & \K{VP}\B{dl}_{C}\B{dr}^{H} \\
\K{Subject}\B{dddrr} && \K{V$'$}\B{dl}_{H}\B{dr}^{C} \\ 
& \K{V$^{0}$}\B{dd} && \K{Object}\B{ddlll} \\ \\
\K{B\"ucher}\Below{books} & \K{kaufte} \Below{bought} 
& \K{Maria}\Below{Maria}
}
\begin{verbatim}
\Tree[.5]{ & \K{VP}\B{dl}_{C}\B{dr}^{H}              \\
\K{Subject}\B{dddrr} && \K{V$'$}\B{dl}_{H}\B{dr}^{C} \\ 
& \K{V$^{0}$}\B{dd} && \K{Object}\B{ddlll}           \\ \\
\K{B\"ucher}\Below{books} & \K{kaufte} \Below{bought} 
& \K{Maria}\Below{Maria}                                }
\end{verbatim}


We also have two kontrolled versions of the branching command, \verb|\Bkk| and
\verb|\Bk|. Both adjust the starting and target positions of branches. They have
three arguments, 1: adjustment of starting position, 2: adjustment of target
position, 3: destination. \verb|\Bk| only allows for vertical adjustments and
has numbers as its first two arguments. \verb|\Bkk| has comma-separated number
pairs as its first two arguments, for horizontal and vertical adjustment of
starting and target position. This gives you full control over the branches.
Some examples:

\begin{minipage}[t]{3cm}
  \fbox{\Treek{3} {\K{DP}\Below{[+definite]}\B[-5]{d}\\
      \K{\emph{the~bible}}}}
           \end{minipage}
           \begin{minipage}[t]{10cm}
\begin{verbatim}
 \fbox{\Treek{3}{\K{DP}\Below{[+definite]}
 \B[-5]{d}\\  \K{\emph{the~bible}} }} 
\end{verbatim}
 \end{minipage} 

\begin{minipage}[t]{3cm}
 \Tree{ & \K{XP} \B{dl}\B{dr}\Bkk{2,0}{2,0}{dr} \\ 
         \K{YP}    & & \K{ZP}}
\end{minipage}
\begin{minipage}[t]{10cm}
\begin{verbatim} 
\Tree{ & \K{XP}\B{dl}\B{dr}\Bkk{2,0}{2,0}{dr} \\ 
\K{YP}& & \K{ZP}}\end{verbatim}
\end{minipage} 


\section{Abbreviations}
\label{sec:abbreviations}

The usage of branching commands can be made much easier by the definition of
macros for most frequently used combinations. These are the ones defined in
\texttt{xyling.sty}. Define new ones if you need them and/or change those given
here: 

\begin{verbatim}
% \D goes to the position in the same column, one row below. 
% The optional argument is the vertical adjustment of the 
% starting position. 

\newcommand{\D}[1][0]{\B[#1]{d}} 
\newcommand{\Dk}[2]{\Bk{#1}{#2}{d}}

% \Dk is the \Bk version, i.e., it has two obligatory arguments 
% defining the vertical adjustments of starting position and 
% target position.

\newcommand{\DL}[1][0]{\B[#1]{dl}} 
\newcommand{\DLL}[1][0]{\B[#1]{dll}} 
\newcommand{\DLLL}[1][0]{\B[#1]{dlll}} 
\newcommand{\DR}[1][0]{\B[#1]{dr}} 
\newcommand{\DRR}[1][0]{\B[#1]{drr}} 
\newcommand{\DRRR}[1][0]{\B[#1]{drrr}} 

\newcommand{\DLk}[2][0]{\Bk{#1}{#2}{dl}} 
\newcommand{\DLLk}[2][0]{\Bk{#1}{#2}{dll}} 
\newcommand{\DLLLk}[2][0]{\Bk{#1}{#2}{dlll}} 
\newcommand{\DRk}[2][0]{\Bk{#1}{#2}{dr}} 
\newcommand{\DRRk}[2][0]{\Bk{#1}{#2}{drr}} 
\newcommand{\DRRRk}[2][0]{\Bk{#1}{#2}{drrr}} 

% Abbreviations for binary branches:

\newcommand{\V}[1][0]{\DL[#1]\DR[#1]}
\newcommand{\VV}[1][0]{\DLL[#1]\DRR[#1]}
\newcommand{\VR}[1][0]{\DL[#1]\DRR[#1]}
\newcommand{\VL}[1][0]{\DLL[#1]\DR[#1]}
\newcommand{\VVV}[1][0]{\DLLL[#1]\DRRR[#1]}
\newcommand{\VVR}[1][0]{\DLL[#1]\DRRR[#1]}
\newcommand{\VVL}[1][0]{\DLLL[#1]\DRR[#1]}
\newcommand{\VLL}[1][0]{\DLLL[#1]\DR[#1]}
\newcommand{\VRR}[1][0]{\DL[#1]\DRRR[#1]}

% Define more if you need them.

% Let's make further abbreviations. A default VP has a 
% \V branch. So let's define \VP accordingly, and likewise 
% Vbar, IP, CP etc.:

\newcommand{\VP}[1][]{\K{VP$_{#1}$}\V}
\newcommand{\Vbar}{\K[.5]{V$'$}\V}

\newcommand{\IP}[1][]{\K{IP$_{#1}$}\V}
\newcommand{\Ibar}{\K[.5]{I$'$}\V}

\newcommand{\CP}[1][]{\K{CP$_{#1}$}\V}
\newcommand{\Cbar}{\K[.5]{C$'$}\V}
\newcommand{\Nbar}{\K[.5]{N$'$}\V}

\newcommand{\PP}[1][]{\K{PP$_{#1}$}\V}
\newcommand{\DP}[1][]{\K{DP$_{#1}$}\V}

\newcommand{\AuxP}[1][]{\K{IP$_{#1}$}\V}
\newcommand{\Auxbar}{\K[.5]{I$'$}\V}

% Nodes reasonably without branch:

\newcommand{\NP}[1][]{\K{NP$_{#1}$}}
\newcommand{\Nzero}[1][]{\K[1]{N$^{0}_{#1}$}}
\newcommand{\Vzero}[1][]{\K[1]{V$^{0}_{#1}$}}
\newcommand{\Izero}[1][]{\K{I$^{0}_{#1}$}}
\newcommand{\Auxzero}[1][]{\K{I$^{0}_{#1}$}}
\newcommand{\Czero}[1][]{\K{C$^{0}_{#1}$}}
\newcommand{\Pzero}[1][]{\K{P$^{0}_{#1}$}}
\newcommand{\Dzero}[1][]{\K{D$^{0}_{#1}$}}

% Note that all of these commands, except for the 
% Xbar nodes, have an optional argument for an index. 
% If you use indices longer than one letter, you might
% need to do horizontal adjustment and have to use 
% \K instead.

% This default system only needs new nodes for the 
% terminals. Let's define \T parallel to \K. 
% \T has a vertical branch to the upper node, text is
% italicised. The optional argument, as before, 
% allows for horizontal adjustment of the text:

\newcommand{\T}[2][0]{\POS[]\POS+(0,2) 
\ar@{-}[u]-(0,4) \POS[]\K[#1]{\textit{#2}}}
\end{verbatim}

The code for the tree on page \pageref{firsttree} can now be reduced
dramatically: 

\begin{verbatim}
\Tree {            &    \VP                       \\ 
          \NP      &           & \Vbar            \\ 
       \T{John}    &  \Vzero   &        &  \NP    \\  
                   & \T{loves} &        & \T{Mary}
      }
\end{verbatim}  

Here is the tree, just to assure you:

\begin{center}
  \Tree {   & \VP                   \\
    \NP &       & \Vbar         \\
    \T{John}&\Vzero &    & \NP      \\
    &\T{loves} & & \T{Mary} }
    \end{center}

Chomskyan syntacticians like movement traces, here is one:

\begin{verbatim}
\newcommand{\Trace}[1][i]{\K[0.5]{t$_{#1}$}}
\end{verbatim}

The optional argument, as with the \verb|\XP|, \verb|\Xzero| commands above, is
the index, here defaulted to `\texttt{i}'. 



\section{Triangles}
\label{sec:triangles}

Phrase structure trees often use triangles as abbreviations for larger
structures which shall not be fledged out in full detail. The command
\verb|\TRi| can be used instead of branching commands, introducing a
triangle:\footnote{Notice that the top node in this tree, S, is inserted exactly
  in the middle between two columns -- due to the horizontal adjustment of
  5.2pc. The horizontal distance between the centers of two neighbour fields is
  10.4pc. The command \texttt{\textbackslash Bkk} is then used to get symmetric
  branches from this position, by adjusting the starting position horizontally
  by 5.2pc. You see that the label and branch placement are not limited to the
  possibilities specified by the grid. It only provides a usually satisfactory
  default.}

\begin{center}
  \Tree{ && \K[5.2]{S}\Bkk{5.2,0}{0,0}{dl}\Bkk{5.2,0}{0,0}{drr}\\ 
         &\NP\TRi &&& \VP \\
& \K{\emph{my beloved}}\Below{\emph{wife}} &&\Vzero && \NP\TRi[2] \\ 
&   && \T{likes}&&\K{\emph{our old house}}
       }
\end{center}

\begin{verbatim}
  \Tree{ && \K[5.2]{S}\Bkk{5.2,0}{0,0}{dl}
                      \Bkk{5.2,0}{0,0}{drr}           \\ 
         &\NP\TRi &&      &    \VP                    \\
& \K{\emph{my beloved}}\Below{\emph{wife}} &&
                  \Vzero  &&            \NP\TRi[2]    \\ 
            &&& \T{likes} && \K{\emph{our old house}} 
       }
\end{verbatim}

Triangles need the nodes they refer to in the next lower row, in particular,
don't forget the node [d] from the insertion point of the triangle. You will
get an error message otherwise. The text below the triangle is inserted in the
field [d] from the insertion point

Notice also that the first column in the tree is empty. It's only purpose is
providing a field for the left bottom edge of the left triangle.

\verb|\TRi| is a symmetric triangle. It has an optional argument, the horizontal
adjustment, negative value makes it narrower, positive value makes it wider, as
exemplified in the triangle for `\emph{our old house}' in the tree above.


\verb|\DTRi| and \verb|\TRiD| are rectangles, \verb|\DTRi| has a [d] branch on
the left, \verb|\TRiD| on the right, the optional argument allows for horizontal
adjustment.

The kontrolled version of the triangle, \verb|\Trik|, has two obligatory
arguments for the left and right horizontal adjustment, which can be specified
separately here. This potentially leads to asymmetric triangles. The syntax
is:\newline \verb|\TRik{left}{right}|, where \verb|\TRik{0}{0} = \TRi[0] = \TRi|.



\section{Links}
\label{sec:links}

It occurs very frequently that relations between elements of a tree shall be
indicated with linking arrows, for instance to illustrate syntactic movement.
Links are inserted with the commands \verb|\Link| and \verb|Linkk|. Both have as
optional argument the line style, which could be one of
\verb|-,->,<-,.,.>,<.,--,|\linebreak \verb|-->,<--,| a.o. \verb|\Linkk| has as
its first argument the curving specification. It is defaulted to 1.33pc in
\verb|\Link|. This might not be sufficient in many cases. The second obligatory
argument of \verb|\Linkk| and the first obligatory argument of \verb|\Link| is
the destination field specification.

\begin{center}
  \Tree{    & \CP \\
    \NP[j] && \Cbar \\
    \T{What}& \Czero[i] && \IP \\
    &\T{did} & \NP && \Ibar \\
    &      &\T{John}&\Trace\Linkk[-->]{2.5}{llu}&&\VP \\
    &      &        &&\Vzero && \Trace[j]\Linkk[.>]{4.5}{-3,-6}\\
    & & &&\T{say}&& }
\end{center}

The code is as follows:

\begin{verbatim}
\Tree{    & \CP \\ 
       \NP[j] && \Cbar \\
       \T{What}& \Czero[i] && \IP \\
              &\T{did} & \NP && \Ibar \\
              &      &\T{John}&\Trace
                           \Linkk[-->]{2.5}{llu}&&\VP \\
              &      &        &&\Vzero && \Trace[j]
                            \Linkk[.>]{4.5}{-3,-6}\\ 
              &      &        &&\T{say}&&               }

\end{verbatim}

Note that it is possible to specify the target location in terms of the number
of `hops', as done for the long link here: \verb|\Linkk[.>]{4.5}{-3,-6}| states
that the target of the link is 3 fields up and 6 fields left of the current
field. This is shorter than specifying it with ``\texttt{uuullllll}''. 

English affix hopping according to Chomsky (1981):

\begin{minipage}[t]{5cm}
  \Tree{ & \IP \\ 
    \NP  &  & \Ibar \\
         &\Izero\D& & \VP \\
         &\Trace  &\Vzero\D & & \NP \\ 
         &        &\K[6]{V+INFL}\Link[<-]{-1,-1}
       }
\end{minipage}
\begin{minipage}[t]{9cm}
\begin{verbatim}
 \Tree{ & \IP                       \\ 
   \NP  &  & \Ibar                  \\
        &\Izero\D& & \VP            \\
        &\Trace  &\Vzero\D & & \NP  \\ 
        &   &\K[6]{V+INFL} \Link[<-]{ul}
       }
\end{verbatim}
\end{minipage}

Finally, the commands \verb|\Link| and \verb|\Linkk| link labels to the left of
the tree. Links which are to the right of the tree, on its top, are specified
with \verb|\UpLink| and \verb|\UpLinkk|:

\begin{minipage}[t]{4cm}
  \Tree{ & \IP \\ \NP &&\Ibar \\ & \Izero &&\K{VP} \UpLink{-2,-2}}
\end{minipage}
\begin{minipage}[t]{8cm}
\begin{verbatim}
\Tree{ & \IP   \\ 
 \NP &   &\Ibar \\ 
     & \Izero &&\K{VP} \UpLink{-2,-2}}
\end{verbatim}
\end{minipage}



\section{Highlighting}
\label{sec:highlighting}

Node labels are often highlighted with surrounding circles or squares, and, in
particular in presentations, with colours. Several ways of doing this are
integrated in \texttt{xyling}. 


\subsection{Highlighting sections of a tree with a rectangle}
\label{sec:treesection}

The command \verb|\QS| draws a rectangle around two fields of the tree specified
by their absolute address. The syntax of the command is: \\
\verb|\QS[line style]{top left corner}{bottom right corner}|. The absolute
address of a field is a number pair. The field ``1,1'' is the top left field of
the grid. The fields in the first row are 1,1 1,2 1,3 etc. Those in the second
row are 2,1 2,2 2,3 etc. Because the field addresses are given in absolute
terms, it makes no difference where within the \verb|\Tree| specification a
\verb|\QS| command appears:

\begin{minipage}[t]{4cm}
  \Tree{ & \VP \\ \NP && \Vbar \\ & \Vzero && \NP \QS{1,1}{2,3}
                                               \QS[.]{2,2}{3,4}
       }
\end{minipage}
\begin{minipage}[t]{10cm}
\begin{verbatim}
  \Tree{     & \VP            \\ 
         \NP &    & \Vbar     \\ 
             & \Vzero && \NP \QS{1,1}{2,3}
                          \QS[.]{2,2}{3,4}
       }
\end{verbatim}
\end{minipage}


\subsection{Highlighting node labels with circles and squares}
\label{sec:circles}

The command \verb|\OO| draws a circle around the node label in the current
field. The command \verb|\QQ| draws a square around it:

\begin{minipage}[t]{4cm}
  \Tree{     & \VP            \\
    \NP\OO &    & \Vbar     \\
    & \Vzero && \NP\QQ }
     \end{minipage}
\begin{minipage}[t]{10cm}
\begin{verbatim}
  \Tree{   & \VP               \\
    \NP\OO &    & \Vbar        \\
           & \Vzero && \NP\QQ    }
\end{verbatim}
\end{minipage}

As you can see, the branches go inside the circles and squares. We need to define
branches which start and/or end at circles or squares.  

The following are branches that always work. Starting point for all branches is
the same point on the circle. This makes branches rather short, and changes the
angles of diagonal branches:


\begin{verbatim}
\newcommand{\BoO}[1]{\Bk{-1.2}{1.2}{#1}} 
% branch with circled start and target

\newcommand{\Bo}[1]{\Bk{-1.2}{0}{#1}}    
% branch with circled start

\newcommand{\BO}[1]{\Bk{0}{1.2}{#1}}     
% branch with circled target
\end{verbatim}

\begin{minipage}[t]{4cm} 
  \Tree{ & \K{VP}\OO\Bo{dl}\Bo{dr} \\
    \NP  &    & \Vbar              \\
    & \Vzero && \NP\QQ }
     \end{minipage}
\begin{minipage}[t]{10cm} 
\begin{verbatim}
  \Tree{ & \K{VP}\OO\Bo{dl}\Bo{dr} \\
    \NP  &    & \Vbar              \\
    & \Vzero && \NP\QQ }
\end{verbatim}
\end{minipage}
 
The two \texttt{[dl]} and \texttt{[dr]} branches are no longer parallel. To get
this, the branches should start at different sides of the circle, as if they
initiated at the old position within the circle:

\begin{verbatim}
\newcommand{\DRo}[1][dr]{\Bkk{1.6,-1}{0,0}{#1}}
\newcommand{\DLo}[1][dl]{\Bkk{-1.6,-1.0}{0,0}{#1}}

\newcommand{\DRoO}[1][dr]{\Bkk{1.6,-1}{-1.8,1}{#1}}
\newcommand{\DLoO}[1][dl]{\Bkk{-1.6,-1}{1.8,1}{#1}}

\newcommand{\DRO}[1][dr]{\Bkk{0,0}{-1.8,1}{#1}}
\newcommand{\DLO}[1][dl]{\Bkk{0,0}{1.8,1}{#1}}
\end{verbatim}

This helps:

\begin{minipage}[t]{4cm} 
  \Tree{ & \K{VP}\OO\DLo\DRo \\
    \NP  &    & \Vbar              \\
    & \Vzero && \NP\QQ }
     \end{minipage}
\begin{minipage}[t]{10cm} 
\begin{verbatim}
  \Tree{ & \K{VP}\OO\DLo\DRo \\
    \NP  &    & \Vbar        \\
    & \Vzero && \NP\QQ }
\end{verbatim}
\end{minipage}

The same has to be done with branches to and from squares:

\begin{verbatim}
\newcommand{\DRq}[1][dr]{\Bkk{1.5,-1}{0,0}{#1}}
\newcommand{\DLq}[1][dl]{\Bkk{-1.5,-1}{0,0}{#1}}

\newcommand{\DRQ}[1][dr]{\Bkk{0,0}{-2,1}{#1}}
\newcommand{\DLQ}[1][dl]{\Bkk{0,0}{2,1}{#1}}

\newcommand{\DRqQ}[1][dr]{\Bkk{1.5,-1}{-2,1}{#1}}
\newcommand{\DLqQ}[1][dl]{\Bkk{1.5,-1}{2,1}{#1}}

\newcommand{\DRoQ}[1][dr]{\Bkk{1.5,-1}{-2,1}{#1}}
\newcommand{\DLoQ}[1][dl]{\Bkk{-1.5,-1}{2,1}{#1}}

\newcommand{\DRqO}[1][dr]{\Bkk{1.6,-1}{-1.8,1}{#1}}
\newcommand{\DLqO}[1][dl]{\Bkk{1.6,-1}{1.8,1}{#1}}

\newcommand{\Dq}{\Dk{-1.1}{0}} 
               % only squared starting node
\newcommand{\DQ}{\Dk{0}{1}} 
               % only squared target node
\newcommand{\DqO}{\Dk{-1.1}{1.2}} 
               % squared start and circled target
\newcommand{\DoQ}{\Dk{-1.3}{1}} 
               % circled start and squared target
\newcommand{\DqQ}{\Dk{-1.1}{1}} 
               % square start and squared target
\end{verbatim}

\begin{minipage}[t]{4cm} 
  \Tree{ & \K{VP}\OO\DLo\DRo       \\
    \NP  &    & \K{V$'$}\DL\DRQ \\
    & \Vzero && \NP\QQ }
     \end{minipage}
\begin{minipage}[t]{10cm} 
\begin{verbatim}
  \Tree{ & \K{VP}\OO\DLo\DRo    \\
    \NP  &    & \K{V$'$}\DL\DRQ \\
         & \Vzero &&    \NP\QQ    }
\end{verbatim}
\end{minipage}

The style file contains many abbreviations for the branch commands including
circles and squares around node labels.



\subsection{Highlighting with Colours}
\label{sec:colours}

Especially in presentations,  colours are an option for highlighting
parts of a tree. \texttt{xypic} uses the postscript extensions to make this
possible. Check the \texttt{xypic} documentation for more on colours, especially
for defining new colours. I defined blue, red, green and gray versions of the
standard commands \verb|\Bkk| and \verb|\Kk| and the commands derived from
them. So it is quite painless to integrate colour:

\begin{minipage}[t]{5cm}
  \Tree{               & \Kred{IP}\Vred \\
    \Kblue{NP}\Bblue{d} &  & \Kred{I$'$}\Vred \\
    \Tblue{John} & \Kred{I$^{0}$} && \Kgray{VP} \Vgray \\
    && \Kgreen{t}\Linkblue{ull}&&\Kgray{V$'$}\Vgray\\
    &&&\Kgray{V$^{0}$}&& \Kgray{NP} }
\end{minipage}
\begin{minipage}[t]{8cm}
\begin{verbatim}
\Tree{               
      & \Kred{IP}\Vred \\
      \Kblue{NP}\Bblue{d} && 
             \Kred{I$'$}\Vred \\
      \Tblue{John}& \Kred{I$^{0}$} && 
                  \Kgray{VP} \Vgray \\
      && \Kgreen{t}\Linkblue{ull}&&
                  \Kgray{V$'$}\Vgray\\
      &&&\Kgray{V$^{0}$}&& \Kgray{NP} }
\end{verbatim}
\end{minipage}

There also are macros for coloured circles and squares around nodes. They are
called \verb|\OOred, \QQred| etc. But they do not fully function yet. They have
to be inserted as first element within a field, right after the \verb|&|, and
must be followed by an empty group, \verb|{}|.

\section{Other Structures}
\label{sec:other}

\subsection{Lexical Functional Grammar}

On the basis of the general commands for grids, labels and branches, it is easy
to define commands for other phrase structure formats, or any kind of graphical
object that mixes text and lines. The following macros help drawing LFG trees:

\begin{verbatim}
\newcommand{\Treelfg}[2][0]{\Treek[#1]{3}{#2}}  
\newcommand{\Klfg}[2][]{%
 \K{$\uparrow _{\textsc{\scriptsize #1}}=\downarrow$}\Below{#2}}  
\newcommand{\Blfg}[1]{\Bk{-5}{0}{#1}}
\newcommand{\Vlfg}{\Blfg{dl}\Blfg{dr}}
\end{verbatim}

Note that \verb|\Klfg| produces two lines: The inheritance specification and the
category label. The optional argument is the grammatical function, which, if
available, is indexed to the \verb|$\uparrow$| in the first line. Here comes an
example:  \vspace*{-3ex}

\begin{minipage}[t]{4.5cm}
\Treelfg{             & \Kk{-5}{S}\Vlfg\\
 \Klfg[su]{NP}\Blfg{d} &            &\Klfg{VP} \Vlfg\\
 \Klfg{N$^{0}$}\Blfg{d}&\Klfg{V$^{0}$}\Blfg{d} && \Klfg[ob]{NP}\Blfg{d} \\
 \K{\emph{John}} &\K{\emph{loves}}& & \K{\emph{Mary}}}
\end{minipage}
\begin{minipage}[t]{9cm}
\begin{verbatim}

\Treelfg{             
            & \Kk{-5}{S}\Vlfg           \\ 
\Klfg[su]{NP}\Blfg{d} &  &\Klfg{VP}\Vlfg\\
\Klfg{N$^{0}$}\Blfg{d}&\Klfg{V$^{0}$}
\Blfg{d}    && \Klfg[ob]{NP}\Blfg{d}    \\
\K{\emph{John}} &\K{\emph{loves}}& & 
                           \K{\emph{Mary}}
        }
\end{verbatim}
\end{minipage}

Much of this can be abbreviated in the manner exemplified above. Feel free to do
so. Command names like \verb|\Klfg| etc. could, of course, also be shortened. 


\subsection{Head Driven Phrase Structure Grammar}

The following structure is from the HPSG introduction book ``Syntactic
Theory. A Formal Introduction'' (second edition, 2003) by Sag, Wasow \&\
Bender, page 207:

\newcommand{\AVMone}{\begin{avm}\@1NP$_{i}$\end{avm}}
\newcommand{\AVMtwo}{\begin{avm} \[ SPR & \q< \@1 \q> \\ COMPS & \q<~ \q> \] \end{avm}}
\newcommand{\AVMthree}{\begin{avm} \[ SPR & \q< \@1 \q> \\ COMPS & \q< \@2 \q> \\
                                      ARG-ST & \q< \@1 , \@2 \q> \]            \end{avm}} 
\newcommand{\AVMfour}{\begin{avm}\@2NP$_{i}$\end{avm}}

 \Treek[3]{3}{ & \K{S}\V \\ \Kk{-1}{\AVMone}\D && \K{VP}
   \Below[-4]{\AVMtwo}\B[-13]{ddl}\B[-13]{ddr}
 \\\K{They} \\
  & \K{V} \Below[-6]{\AVMthree} && \Kk{-1}{\AVMfour}\B{dd}\\ &\K{}\D[-1] \\ &\K{saw} && \K{themselves}}

How did we draw the tree? First, we use Christopher Manning's avm.sty to define the AVM
structures of each node separately:

\begin{verbatim}
\newcommand{\AVMone}{\begin{avm}\@1NP$_{i}$\end{avm}}
\newcommand{\AVMtwo}{\begin{avm} 
                      \[    SPR & \q< \@1 \q> \\ 
                          COMPS & \q<~ \q> \] \end{avm}}
\newcommand{\AVMthree}{\begin{avm} 
               \[   SPR & \q< \@1 \q> \\ 
                  COMPS & \q< \@2 \q> \\
                 ARG-ST & \q< \@1 , \@2 \q> \] \end{avm}} 
\newcommand{\AVMfour}{\begin{avm}\@2NP$_{i}$\end{avm}}
\end{verbatim}

Next, we make up the tree, and call the four AVM nodes within \verb|\K| or
\verb|\Below|. The most tricky issue is the determination for the tree widths and how to
deal with the unequal sizes of the nodes. As you see in the code below, I exploited
three features of xyling: setting row and column distance to a new value, adjusting
branches, and the huge nodes VP and V were extended over two rows!

\footnotesize
\begin{verbatim}
   \Treek[3]{3}{   & \K{S}\V \\                                   % adjust grid!
\Kk{-1}{\AVMone}\D && \K{VP}
                    \Below[-4]{\AVMtwo}\B[-13]{ddl}\B[-13]{ddr}\\ % Branches go ddr/ddl!
       \K{They}                                                \\ % skipped row for VP!
                & \K{V} 
               \Below[-6]{\AVMthree} && \Kk{-1}{\AVMfour}\B{dd}\\ % Branch goes dd!
                &\K{}\D[-1]                                    \\ % Branch starts here!
                &\K{saw}             && \K{themselves}}

\end{verbatim}
\normalsize

Note an incompatibility of avm.sty: When I first experimented with xyling.sty and
avm.sty, the linebraks in my avm's disappeared. It took me a while to figure out that
this was not due to xyling, but caused by the tabularx package which I had loaded for
another purpose. So, if you use avm.sty, don't use tabularx!

\subsection{Arrows in Text}
\label{sec:text}

Even when we do not use trees, but only strings or bracketed notations, we
sometimes want to express relations between elements within these notations by
arrows. It is possible to use \texttt{xyling} macros for this, too. We first
define a new grid, \verb|\TExt|. It has an obligatory argument -- the text,
which can be split into several fields by the field separator \verb|&|. The
distance between fields is set to 0, such that even parts of words can be put in
subsequent fields without visible effect:

\begin{minipage}[t]{3cm} 
  \TExt{\textnormal{nood} & \textnormal{les}&\textnormal{~~}&
    \textnormal{noodles}}
\end{minipage}  
\begin{minipage}[t]{8cm} 
\begin{verbatim}
  \TExt{\textnormal{nood} & \textnormal{les} & 
        \textnormal{~~} & \textnormal{noodles}}\end{verbatim}
\end{minipage}

The fields within the \verb|\TExt| environment are inserted with \verb|\Txt| or 
\verb|\TXT|. They mainly provide a strut to yield correct horizontal alignment. 
\verb|\Txt| has a blank before the text, \verb|\TXT| has none. I.e., if a word
is split over two fields, the second part of the word should be introduced with 
\verb|\TXT|.  Likewise, the first word of the whole string.

The arrows differ in their depths, such that several arrows can be used within
one \verb|\TExt| without overlapping. The narrowest connector is called
\verb|SCOn|, we then have \verb|\COn, \COnn| and \verb|\COnnn|. They have an
optional argument for the line style, \verb|-| for solid, \verb|--| for dashed,
\verb|.| for dotted. The commands are inserted at the starting point of the
arrow. The obligatory argument is the target field destination, e.g.
\texttt{[ll]}, \texttt{[r]} etc. A simple example:

\begin{minipage}[t]{5cm}
  \TExt{\TXT{What} & \Txt{did you see} & \Txt{t}\COn{ll} & \Txt{?}}
\end{minipage}
\begin{minipage}[t]{9cm}
\begin{verbatim}
\TExt{\TXT{What} & \Txt{did you see} & 
\Txt{t}\COn{ll} & \Txt{?}}
\end{verbatim}
\end{minipage}

The command \verb|\COnk| allows for control of the link depth with its first
obligatory argument. The other arguments are as before. 

We also have connectors with labels, which can be above or below the arrow. This
depends on whether the arrow goes from left to right or vice versa. \verb|\COnl|
with right to left yields a label above the arrow:

\begin{minipage}[t]{5cm}
  \TExt{\TXT{What} & \Txt{did you see} & \Txt{t}\COnl{ll}{movement} & \Txt{?}}
\end{minipage}
\begin{minipage}[t]{9cm}
\begin{verbatim}
\TExt{\TXT{What} & \Txt{did you see} & 
\Txt{t}\COnl{ll}{movement} & \Txt{?}}
\end{verbatim}
\end{minipage}

\begin{minipage}[t]{5cm}
  \TExt{\TXT{What} & \Txt{did you see} & \Txt{t}\COnr{ll}{movement} & \Txt{?}}
\end{minipage}
\begin{minipage}[t]{9cm}
\begin{verbatim}
\TExt{\TXT{What} & \Txt{did you see} & 
\Txt{t}\COnr{ll}{movement} & \Txt{?}}
\end{verbatim}
\end{minipage}

\subsection{Autosegmental Phonology}

Not being an phonologist, I can only offer some beginner's applications, but I will
gladly add macros that you might supply. Just send them to me. Here is one application
that is based on the previously introduced \verb|\TExt| matrix. It is not limited to
having just one row, and one application of this feature are the structures used in
autosegmental phonology. Have a look at this:

\TExtk[1]{1}{ 
\Tname[5]{Root tier:}&
\Sl{k}    &      & \Sl{t}   &      &\Sl{b}    &      \\
\Tname[5]{Skeletal tier:}&
\Sl{C}\Lnu&\Sl{V}&\Sl{C}\Lnu&\Sl{V}&\Sl{C}\Lnu&\Sl{V}\\
\Tname[5]{Vocalic melody tier:}&
          & \Sl{a}\Lnu\Lnd{urr}\Lnd{urrrr} 
}

The code uses the kontrolled matrix for text, \verb|\TExtk|, with inter-column
space in pc as mandatory argument, and inter-row space in pc as optional argument. The
command \verb|\Sl| provides the slots of the tier. At the beginning of each row, the
tier's name is given with the macro \verb|\Tname| which has as optional argument the
name width in cm. Links between slots are variants of our branch commands, \verb|\Ln|
draws a solid line, and \verb|\Lnd| a dashed line. \verb|\Lnu| is an abbreviation for
\verb|\Ln{u}|. Define more macros, if you need them. By the way, the example above is
Arabic for `he/she wrote'. This is the code:\newpage

\begin{verbatim}
\TExtk[1]{1}{ 
\Tname[5]{Root tier:}&
\Sl{k}    &      & \Sl{t}   &      &\Sl{b}    &      \\
\Tname[5]{Skeletal tier:}&
\Sl{C}\Lnu&\Sl{V}&\Sl{C}\Lnu&\Sl{V}&\Sl{C}\Lnu&\Sl{V}\\
\Tname[5]{Vocalic melody tier:}&
          & \Sl{a}\Lnu\Lnd{urr}\Lnd{urrrr} 
}
\end{verbatim}


\subsection{Graphical Schemata -- Arrows instead of lines}

The branching command is based on the \texttt{xypic} arrow command
\verb|\ar|. It can do a lot more than just drawing solid lines. It can, for
instance, draw arrows. As this is sometimes useful, we integrate an arrow
command, \verb|\AR|:

\begin{verbatim}
\newcommand{\ARkk}[3]{\POS[]-(0,4)+(#1)\ar@{->}[#3]+(0,2)+(#2)}
\newcommand{\ARk}[3]{\ARkk{0,#1}{0,#2}{#3}}
\newcommand{\AR}[2][0]{\ARk{#1}{0}{#2}}
\end{verbatim}

This helps us draw the GB schema:

\begin{minipage}[t]{4cm}
\fbox{%
  \Treek[.5]{3}{ & \K{D-Structure}\AR{d} \\
    & \K{S-Structure} \AR{dl}\AR{dr}\\
    \K{LF} & & \K{PF} }}
\end{minipage}
\begin{minipage}[t]{10cm}
  The code is rather small:
\begin{verbatim}
\fbox{
  \Treek[.5]{3}{ 
         & \K{D-Structure}\AR{d}         \\
         & \K{S-Structure} \AR{dl}\AR{dr}\\
    \K{LF} &          & \K{PF}           } 
     }
\end{verbatim}
\end{minipage}

We can also use alternative line styles, like dashes, dots, and waves:


\begin{verbatim}
\newcommand{\Bdot}[2][0]{\POS[]-(0,4)\POS+(0,#1)%
                         \ar@{.}[#2]+(0,2)}
\newcommand{\ARdot}[2][0]{\POS[]\POS-(0,4)\POS+(0,#1)%
                         \ar@{.>}[#2]+(0,2)}

\newcommand{\Bdash}[2][0]{\POS[]-(0,4)\POS+(0,#1)%
                         \ar@{--}[#2]+(0,2)}
\newcommand{\ARdash}[2][0]{\POS[]\POS-(0,4)\POS+(0,#1)%
                         \ar@{-->}[#2]+(0,2)}

\newcommand{\Bwav}[2][0]{\POS[]-(0,4)\POS+(0,#1)%
                         \ar@{~}[#2]+(0,2)}
\newcommand{\ARwav}[2][0]{\POS[]\POS-(0,4)\POS+(0,#1)%
                          \ar@{~>}[#2]+(0,2)}
\end{verbatim}\enlargethispage{-2\baselineskip}

Joost Kremers, University of Frankfurt/Main, $<$j.kremers@em.uni-frankfurt.de$>$, has
kindfully defined a ``generalised branch'' command that I happily integrate here:

\begin{verbatim}
\newcommand{\GBkk}[4]{\POS[]-(0,4)+(#1)\ar@{#4}[#3]+(0,2)+(#2)}
\newcommand{\GBk}[4]{\GBkk{0,#1}{0,#2}{#3}{#4}}
\newcommand{\GB}[3][0]{\GBk{#1}{0}{#2}{#3}}
\end{verbatim}

The branch commands are the same as the \verb|\Bkk|, \verb|\Bk| and \verb|\B| commands,
except that they have one more mandatory argument, and the final mandatory argument is
the line style, which can be as follows:


\begin{tabular}[t]{ll}
  - &solid line \\
 -- &dashed line \\
 = &double line \\
 == &dashed double line \\
 . &dotted line \\
 : &dotted double line \\
 \texttildelow &wavy line \\
 \texttildelow\texttildelow &dashed wavy line \\
\end{tabular}

To yield arrows, you only need to extend the line style with leading or final \verb|<|
or \verb|>|, as e.g. in \verb|\GB{=>}{dl}|. 

\Tree{ & \K{VP}\GB{dl}{=}\GB{dr}{=}\\ && }
\begin{minipage}{.5\linewidth}
\begin{verbatim}
\Tree{ & \K{VP}\GB{dl}{=}\GB{dr}{=}\\ && }
\end{verbatim}
  \end{minipage}
  
The minimalist syntax model is often schematised with a dashed arrow to PF:

\begin{minipage}[t]{3.5cm}
  \fbox{
    \Treek{2.5}{ \K{\emph{Lexicon}}\AR{dd}  \\
      \ARdash[3]{dr} & \K{\emph{Spell-out}}\\
      \K{LF} & \K{PF} } }
   \end{minipage}
   \begin{minipage}[t]{10cm}
\begin{verbatim}
\fbox{
 \Treek{2.5}{ 
 \K{\emph{Lexicon}}\AR{dd}  \\
    \ARdash[3]{dr} & \K{\emph{Spell-out}}\\
         \K{LF}    & \K{PF} } }\end{verbatim}
   \end{minipage}

It might sometimes be useful to have branches and arrows to the field on the
right in the same row. The command \verb|\R| makes this possible. The syntax is:
\verb|\R[line style]{destination}|. If you want to, you can write phrase
structure rules that way {\ldots} {\large\smiley} {\ldots} :

\Tree[-1]{\K{S}\R[->]{rr} && \K[5]{NP~~VP}} 

\verb|\Tree[-1]{\K{S}\R[->]{rr} && \K[5]{NP~~VP}}| 

Versions of \verb|\R| that link circles and squares are also defined in
\texttt{xyling.sty}. Another funny application are neural nets:
\begin{center}
\fbox{
  \begin{minipage}[t]{.75\textwidth}~\\
    \Treek[.5]{4}{\K[-2]{\emph{Layer 1}}&&& 
      \OO \DLLoO\DLoO \DoO \DRoO\DRRoO\DRRRoO\DRoO[drrrr]& 
      \OO \DLLLoO\DLLoO\DLoO \DoO \DRoO\DRRoO\DRRRoO & 
      \OO \DLoO[dllll]\DLLLoO\DLLoO\DLoO \DoO \DRoO\DRRoO \\ 
      \K[-2]{\emph{Layer 2}}& 
      \OO \BoO{drr}\BoO{drrr}\BoO{drrrr} \RoO{r} & 
      \OO \BoO{dr}\BoO{drr}\BoO{drrr} \RoO{r} & 
      \OO \BoO{d}\BoO{dr}\BoO{drr} \RoO{r} & 
      \OO \BoO{dl}\BoO{d}\BoO{dr} \RoO{r} & 
      \OO \BoO{dll}\BoO{dl}\BoO{d} \RoO{r} &  
      \OO \BoO{dlll}\BoO{dll}\BoO{dl} \RoO{r} & 
      \OO \BoO{dllll}\BoO{dlll}\BoO{dll} \\
      \K[-2]{\emph{Layer 3}} &&&\OO & \OO & \OO } 
   \end{minipage}
   }
 \end{center}

\begin{verbatim}
 \Treek[.5]{4}{
   \K[-2]{\emph{Layer 1}}&&& 
     \OO \DLLoO\DLoO \DoO \DRoO\DRRoO\DRRRoO\DRoO[drrrr]& 
     \OO \DLLLoO\DLLoO\DLoO \DoO \DRoO\DRRoO\DRRRoO & 
     \OO \DLoO[dllll]\DLLLoO\DLLoO\DLoO \DoO \DRoO\DRRoO \\ 
   \K[-2]{\emph{Layer 2}}& 
     \OO \BoO{drr}\BoO{drrr}\BoO{drrrr} \RoO{r} & 
     \OO \BoO{dr}\BoO{drr}\BoO{drrr} \RoO{r} & 
     \OO \BoO{d}\BoO{dr}\BoO{drr} \RoO{r} & 
     \OO \BoO{dl}\BoO{d}\BoO{dr} \RoO{r} & 
     \OO \BoO{dll}\BoO{dl}\BoO{d} \RoO{r} & 
     \OO \BoO{dlll}\BoO{dll}\BoO{dl} \RoO{r} & 
     \OO \BoO{dllll}\BoO{dlll}\BoO{dll} \\
   \K[-2]{\emph{Layer 3}} &&&\OO & \OO & \OO } 
\end{verbatim}
 
Compare the two different connection styles between layers 1,2 and 2,3,
respectively. 




\section{Some Extras}
\label{sec:extras}

These are two handy macros for constructing metrical grids and glosses. They
have nothing to do with \texttt{xypic}. I include them because I find them
useful. 

\paragraph{Metrical Grids}

The command \verb|\PX| has one obligatory argument, the piece of text which is
to receive grid marks, and, as optional argument, the number of grid marks,
defaulted to 1:

\begin{minipage}[t]{4cm}
  \PX[2]{Fa}rah \PX{Faw}cett \PX[3]{Ma}jors
\end{minipage}
\begin{minipage}[t]{5cm}
\begin{verbatim}
  \PX[2]{Fa}rah \PX{Faw}cett \PX[3]{Ma}jors
\end{verbatim}
\end{minipage}

\verb|\PX| has center alignment of text and mark, for left and right alignment
use \verb|\PXl| and \verb|PXr|. These macros require the \texttt{ifthen}
package. 


\paragraph{Glosses}
For linguistic glosses, I normally use \texttt{cgloss4e.sty}. But when I want to
gloss only one or two words within an example, \texttt{cgloss} is not that
handy, as you must make as many glosses as there are words within an example,
which leads to a sequence of empty groups. \verb|\PG| has two arguments for the
word and its gloss:

\begin{minipage}[t]{3cm}
  \PG{John}{\textsc{nom}} loves \PG{Mary}{\textsc{acc}}
\end{minipage}
\begin{minipage}[t]{7cm}
\begin{verbatim}
  \PG{John}{\textsc{nom}} loves 
  \PG{Mary}{\textsc{acc}}
\end{verbatim}
\end{minipage}

\verb|\PG| aligns word and gloss at the left edge, for center and right
alignment use \verb|\PGc| and \verb|\PGr|. 


\bigskip

For bug reports, comments and suggestions, contact:\\
\texttt{rvogel@ling.uni-potsdam.de}



\end{document}