summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xytree/xytree-doc-en.tex
blob: 24aa6d900508e53a4843beebed8d8fc7cf159263 (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
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
%&pdflatex
\documentclass[a4paper]{article}

\usepackage{xytree}
\usepackage{a4wide}
\usepackage{multicol}
\usepackage{avm,cm-lingmacros}

\usepackage{fullname}

\newcommand{\ttbs}{\char92}
\ifx\pdftexversion\undefined
\usepackage[dvips,colorlinks=false]{hyperref}
\else
\usepackage[pdftex,colorlinks=false]{hyperref}
\fi

\parskip\bigskipamount

\begin{document}

\title{\textsf{xytree.sty} --- A \LaTeX{} package for drawing
  syntactic trees (version 1.5)}

\author{Koaunghi Un}

\date{2006/8/15}

\maketitle

\begin{quotation}
  \begin{center}
    \bfseries \large Abstract
  \end{center}
  
  \textsf{xytree.sty} utilizes the \Xy-pic package to draw syntactic
  trees.  There are currently some similar \LaTeX{} packages for this
  purpose, but they have strength and weakness, so one allows to draw
  only binary trees and the other permits to draw only limited sorts
  of lines.  Some packages provide quasi perfect solution in this
  area, but have the dependency on the other graphic language, which
  \texttt{dvi} driver can not directly process.

  The aim of \textsf{xytree.sty} is to draw linguistic syntactic trees
  with ease and to support hopefully sufficient functionality, that
  the linguist may need.

  In the version of 1.5, a functionality is added for semanticists to
  draw DRS (Discourse Representation Structure).
\end{quotation}

%\tableofcontents

\bigskip

\begin{multicols}{2}

\section{Introduction}
\label{sec:intro}

\textsf{xytree.sty} is based on the powerful vector drawing package,
\Xy-pic.  Although \namecite{vogel00} takes the same approach, it's
functionality is somehow limited to fulfill linguists' needs.

With \textsf{parsetree.sty} linguists can draw syntactic trees
relatively easily, though without curved lines and arrows.  Moreover a
node can have only three or less daughter. See
\namecite{arnold97:_packag_drawin_trees_latex}.

\textsf{tree-dvips.sty} by Emma Pease would be the best in this
contest.  Indeed it provides all the functionality, which
\textsf{xytree.sty} does.  The main strength and weakness in the same
time in this package is the use of \verb+\special+ command.  The
PostScript language inside this command draws the lines to construct
the desired tree.  But, the \verb+\special+ command in the \verb+dvi+
file can only be processed by \verb+dvi+ drivers, which understand
PostScript language.  Consequently, the output of
\textsf{tree-dvips.sty} requires an unpleasant handling.  That is,
some previewers like \verb+xdvi+ can not show the lines drawn by
\textsf{tree-dvips.sty}.  Secondly, PDF file cannot be produced by
\verb+pdflatex+, because the PostScript prologue of
\textsf{tree-dvips.sty} isn't compatible with PDF specification.  In
order to make a PDF file, an intermediate PS file between \verb+dvi+
and PDF is indispensable.

Such a cold comfort was due to the weakness of \LaTeX{} in the field
of graphics, which can now be supplemented by \Xy-pic{} package.  See
\namecite{rose99:_xy_guide,rose99:_xy_refer_manual}.

\section{Loading xytree.sty}
\label{sec:basics}

In order to use \textsf{xytree.sty}, put the following line between
\verb|\documentclass| and \verb|\begin{document}| as shown in \ex{1}.
% 
\begin{example}\label{usepackage}
\begin{verbatim}
\usepackage{xytree}
\end{verbatim}
\end{example}


\section{Usage}
\label{sec:usage}

As an experience, it would be advisable to analyze trees as lattice
structure before doing the actual task.

\begingroup
\xy
\def\objectstyle{\hbox}
\xymatrix @W=1.7pc @H=1pc @R=0pc @C=0pc @*[F.]{
  & & & S & & & \\
  & NP & & & & VP & \\
  Det & & N & & V & NP & PP
}
\drop\frm{-}
\endxy
\endgroup
\noindent
The vertical dotted lines between two adjacent cells in the above
diagram can be replaced by \verb+&+'s and the rightmost lines can be
replaced by \verb+\\+.  The \verb+&+'s delimiting empty cells on the
right side of a line are optional and the last \verb+\\+ can be also
omitted.

The next step is to specify nonempty cells as node.  The tree can be
finished up by drawing lines, which connect nodes as shown
below.\footnote{The outer dotted line denotes the range of drawn
  trees.}

\xy
\def\objectstyle{\hbox}
\xytree{
  & & & \xynode[-2,2]{S} \\
  & \xynode[-1,1]{NP} & & & & \xynode[-1,0,1]{VP} \\
  \xynode{Det} & & \xynode{N} & & \xynode{V} & \xynode{NP} & \xynode{PP} \\
}
\drop\frm{.}
\endxy

In the following, macros for node declaration, node connection, etc.
will be explained.


\subsection{\textbackslash xytree}

A tree is drawn with a \verb+\xytree+ macro and it's general syntax looks
like \ex{1}.
\begin{example}\label{xytree}
  \begin{verbatim}
 \xytree[col spacing]{matrix}
  \end{verbatim}
\end{example}
%
\verb|\xytree| takes an optional and a mandatory argument.  The
optional argument \texttt{[col spacing]} controls the horizontal
distances between two adjacent nodes.  The value should be positive
decimal numeral in unit of \textsf{pc} (1\textsf{pc}=12\textsf{pt}).
The default is \textsf{0.5}.  The mandatory argument \verb+matrix+ is
the actual content of a tree, consisting of nodes and delimiters.

Below, an output of \verb+\xytree+ with its source code is shown.

\begingroup
\renewcommand{\baselinestretch}{1.0}\normalsize
\begin{verbatim}
\xytree{
  \xynode{A} & \xynode{B} \\
  \xynode{C} & \xynode{D}
}
\end{verbatim}
\endgroup

\hfil\xy
\xytree{
  \xynode{A} & \xynode{B} \\
  \xynode{C} & \xynode{D}
}
\drop\frm{.}
\endxy

The row spacing can be given with \verb+\rowheight+ before
\verb+\xytree+ begins.  The default is \textsf{2pc}.  An example with
smaller \verb+\rowheight+ is shown below.
\begin{verbatim}
\rowheight=0.5pc
\xytree{
  \xynode{A} & \xynode{B} \\
  \xynode{C} & \xynode{D}
}
\end{verbatim}
\bgroup\rowheight=0.5pc
\hfil\xy
\xytree{
  \xynode{A} & \xynode{B} \\
  \xynode{C} & \xynode{D}
}
\drop\frm{.}
\endxy
\egroup

In case of wider entry in nodes like AVM, \texttt{[col spacing]} tends
to grow.  If a tree should have some labels on the connecting lines
between nodes, \verb+\rowheight+ will be useful.  For AVM, confer
\namecite{pease00:_linguis_macros} or \namecite{manning93}.


\subsection{\textbackslash xynode}
\label{subsection:xynode}

A tree reaches completion, when all nodes are specified and necessary
lines are drawn to connect nodes.  \verb+\xynode+ declares and
connects nodes inside one macro.  A simple tree can be completed only
with \verb+\xynode+ command.  This command has the form like \ex{1}.
%
\begin{example}\label{xynode}
\begin{verbatim}
\xynode[lower nodes]{entry}
\end{verbatim}
\end{example}
%
\texttt{[lower nodes]} is integer numbers delimited by comma.  Each
number denotes the relative positions of target nodes to be connected
from the current node with straight line.  The position is counted
relatively, e.g.  \verb+0+ is the node directly under the current
node, \verb+1+ is the first node rightwards under the current node.
Likewise, \verb+-2+ is the second node leftwards under the current
node.

In the following tree, the node with starting line is \textsf{S}.
\verb+-1+ connects to the node \textsf{NP} and \verb+1+ connects to
the node \textsf{VP}.

\begin{verbatim}
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}
}
\end{verbatim}
\hfil\xy
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}
}
\drop\frm{.}
\endxy

\noindent
\verb|{entry}| is the content of the current node and in many cases it
is the phrasal sign of the syntactic structure.


\subsection{\textbackslash xytrinode}

A triangle instead of a line is used if the daughter node is not a
sort of \textsf{word}.  In order to draw a triangle, use
\verb+\xytrinode+ like \ex{1}.
\begin{example}\label{xytreenode}
\begin{verbatim}
\xytrinode[width]{entry}
\end{verbatim}
\end{example}

An example follows:
\begin{verbatim}
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode[0]{NP} & & \xytrinode{VP} \\
  \xyterminal{It} & &
  \xyterminal{is raining}
}
\end{verbatim}
\hfil\xy
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode[0]{NP} & & \xytrinode{VP} \\
  \xyterminal{It} & &
  \xyterminal{is raining}
}
\drop\frm{.}
\endxy

As a default the base of the triangle is as wide as the width of the
entry.  Though, a different value can be specified with
\texttt{[width]}.  If it is a positive real number the triangle will
have longer base, and if it is a negative real number the width will
be shorter.  The unit of \texttt{[width]} is \textsf{mm}.

The following example shows an output of a tree with shorter base
length using \texttt{[5]}.

\begin{verbatim}
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode[0]{NP} &
  & \xytrinode[-5]{VP}\\
  \xynode{It} & & \xynode{is raining}
}
\end{verbatim}
\hfil\xy
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode[0]{NP} & & \xytrinode[-5]{VP} \\
  \xyterminal{It} & & \xyterminal{is raining}
}
\drop\frm{.}
\endxy

The mandatory argument \verb+{entry}+ is the content of the tree node
as explained in the \verb+\xynode+.


\subsection{\textbackslash xyterminal}

As shown in the above examples, the leaf nodes as phonological
representation of the phrasal signs are written in italic shape.  The
command \verb+\xyterminal+ is intended to be used for such leaf nodes.
This command replaces \verb+\xynode+ command and it has no optional
argument for the connecting lines with the daughters.

The general syntax is as \ex{1}.
\begin{example}\label{xyterminal}
\begin{verbatim}
\xyterminal{entry}
\end{verbatim}
\end{example}


\subsection{\textbackslash xyconnect}
\label{subsection:xyconnect}

For simple syntactic trees, I think, no more commands need to be
added.  For complicated syntactic trees, though, this line connecting
macro is useful.  It's general syntax is as \ex{1}.\footnote{Because
  of limited paper width a long line is broken into several ones.}
%
\begin{example}\label{xyconnect}
\begin{verbatim}
\xyconnect
        [arrow form]
        [bending of line]
        (start pos, end pos)
        {target node number}
        "label of line"
\end{verbatim}
\end{example}
%
The fourth argument is mandatory, and all the others are optional.  In
other word, given the pair of \texttt{\{target node number\}}, a line is
drawn with default values.

\texttt{[arrow form]} is the optional argument for specifying the form of
arrow.  The default value is \verb+-+, straight line.  An arrow
consists of tail, shaft, and nib.  The nib and tail can be chosen with
\verb|<|, \verb|>|, \verb|(|, \verb|)|, \verb+|+, \verb|+|, \verb|/|
and the shaft with \verb|-|, \verb|--|, \verb|.|, \verb|~|, \verb|~~|,
\verb|=|, \verb|:|.

Without nib and tail, it is a line.  But without shaft, no arrow is
formed.

Examples forming the arrows with proper combination of tail, shaft,
and nib are shown below.  The order of the combination is
\texttt{[tail~shaft nib]}, and \texttt{tail} and \texttt{nib} can be
omitted.
%
\newcommand{\myarrow}[2][\empty]{
  \ifx\empty#1\relax\texttt{#2}\else
  \texttt{#1}\fi &
  \xytree{
    \xynode{}
    \xyconnect[#2](R,L){0,1}
    &
    \xynode{}
  }}
\begin{center}\tabcolsep3pt
  \begin{tabular}{|ll|ll|ll|}\hline
    \myarrow{-} &
    \myarrow{--} &
    \myarrow{.} \\
    \myarrow{:} &
    \myarrow[\~{}]{~} &
    \myarrow[\~{}\~{}]{~~} \\
    \myarrow{=} &
    \myarrow{==} & &
    \\\hline
    \myarrow{|->} &
    \myarrow{<->} &
    \myarrow{(-+} \\
    \myarrow{(.)} &
    \myarrow{>.<} &
    \myarrow{/.+}
    \\\hline
  \end{tabular}
\end{center}

The second optional argument \texttt{[bending of line]} is used to
draw curved lines.

\newcommand{\infl}[1]{%
  \xytree[1]{\xynode{X}\xyconnect[->][#1](R,L){0,1} & \xynode{X$'$}}}
\begin{center}
\begin{tabular}{|ll|}\hline
  \verb|[^]| & \infl{^} \\
  \verb|[_]| & \infl{_} \\
  \verb|[_1pc]| & \infl{_1pc}\\\hline
\end{tabular}
\end{center}
As can be noted from the above example, \verb+^+ bends lines to upward
direction and \verb+_+ to downward direction.  This directionality is
determined by stretching a line from left to right.  If the direction
of a line is from right to left, the bending direction reverses.
Given by some value of dimension after the direction sign, the amount
of the inflection is specified by that value.  \verb+1pc+ in the above
example (the last one) bends the line downwards by 1\textsf{pc}.

The third optional argument \texttt{(start pos, end pos)} consists of
a comma-separated pair of position markers.  The first marker is for
the start position of the line and the second for the end position.
The markers are denoted by one or two uppercase letters as shown
below.

\medskip
\def\corner#1{\POS"box"+0;"box"+#1 **@{-} ?>*@{>} +/1pc/ *\hbox{\tt#1}}
%
\hfil\xy 0.(-11,-6).(11,6)!C="box"*\frm{.},"box";
 "box"+L**@{.}, "box"+R**@{.}, "box"+D**@{.}, "box"+U**@{.}
%
 \corner{L} \corner{R} \corner{D} \corner{U}
 \corner{DL}\corner{DR}\corner{UL}\corner{UR}
\endxy

And some examples follow.
\begin{center}
\newcommand{\bend}[1]{%
  \xytree[1]{\xynode{X}\xyconnect[->][^](#1){0,1} & \xynode{X$'$}}}
\begin{tabular}{|ll|}\hline
  default & \bend{D,U} \\
  \verb|(UL,DR)| & \bend{UL,DR} \\
  \verb|(DR,UL)| & \bend{DR,UL} \\
  \verb|(U,D)| & \bend{U,D} \\\hline
\end{tabular}\\
\end{center}
The default is \textsf{(D,U)}.

\verb|{target node number}| is the only mandatory argument in this
command.  It is a pair of integers delimited by a comma.  The first
integer number is responsible for the relative row number of the target
node against the current node, and the second for the relative column
number.  If the target node is placed above the current node, the
relative row number must be negative, and vice versa.  Likewise, if
the target node is in the left side of the current node, the column
number must be negative, and vice versa.  This is the same
directionality as of \verb+\xynode+ command.  In case of
\verb+\xynode+, the relative row number of the target node is always
\verb+1+, so only the relative column number(s) of the target node
is(are) to be specified as optional argument.

The matrix size of the tree below is $4\times 3$, which means 4
columns and 3 rows.

\hfil\xy
\xytree{ & \xynode[-1,1]{XP} \\
  \xynode{...} & & \xynode[-1,1]{X$'$} \\
  & \xynode{X} & & \xynode{Y}}
\drop\frm{.}
\endxy

The absolute position of the node \textsf{XP} is represented as \verb+"1,2"+.
From this node as current node, all the directionality of
\verb+\xyconnect+ can be summarized as follows.
\begin{center}
\begin{tabular}{|lll|}\hline
  node & abs. pos & directionality \\\hline
  ... & \verb|"2,1"| & \verb|{1,-1}| \\
  X$'$ & \verb|"2,3"| & \verb|{1,1}| \\
  X & \verb|"3,2"| & \verb|{2,0}| \\
  Y & \verb|"3,4"| & \verb|{2,2}| \\\hline
\end{tabular}
\end{center}
To be clearer, the diagram below will show the relative positions as
labels on the connecting lines.

\hfil\xy
\xytree[2]{ & \xynode{XP}
  \xyconnect[.>]{1,-1}"_{\{$1,-1$\}}"
  \xyconnect[.>]{2,0}"|{\{$2,0$\}}"
  \xyconnect[.>]{1,1}"^{\{$1,1$\}}"
  \xyconnect[.>][_1pc]{2,2}"_{\{$2,2$\}}"
  \\
  \xynode{...} & & \xynode{X$'$}
  \\
  & \xynode{X} & & \xynode{Y}}
\drop\frm{.}
\endxy

The last argument of \verb+\xyconnect+, \texttt{"label of line"} is
optional, which puts labels on the connecting line.  Labels will be by
default centered on the line.  Basically, there are three kinds of
label formats.  As can be noticed in the above diagram, the label on
the line between \textsf{XP} and \textsf{X$'$} is typeset as \verb+"^{1,1}"+,
the label on the line between \textsf{XP} and \textsf{Y} as \verb+"_{2,2}"+, and
the label on the line between \textsf{XP} and \textsf{X} as \verb+"|{2,0}"+.
The directionality of the label position is the same as the one of the
line bending, e.g. if a line starts from left to right, \verb+_+ puts
labels below the line, \verb+^+ above the line.  Because \verb+|+
breaks the line, the directionality means nothing.
\begin{center}
  \begin{tabular}{|ll|}\hline
    \verb|"^{label}"| &
    \xytree[4]{\xynode{}\xyconnect[->](R,L){0,1}"^{label}" &} \\
    \verb+"|{label}"+ &
    \xytree[4]{\xynode{}\xyconnect[->](R,L){0,1}"|{label}" &} \\
    \verb|"_{label}"| &
    \xytree[4]{\xynode{}\xyconnect[->](R,L){0,1}"_{label}" &} \\\hline
  \end{tabular}
\end{center}

To put labels in the different position on the line than in the
middle, type the displacement character directly after the
directionality character as follows.
\begin{center}\tabcolsep3pt
  \begin{tabular}{|lll|}\hline
    \verb|^<{x}| & \unskip
    \xytree[2]{\xyconnect[->](R,L){0,1}"^<{x}" &} &
    start pos of the line \\
    \verb|^<<{x}| &
    \xytree[2]{\xyconnect[->](R,L){0,1}"^<<{x}" &} &
    more \verb|<|  \\
    \verb|^>{x}| &
    \xytree[2]{\xyconnect[->](R,L){0,1}"^>{x}" &} &
    end of line \\
    \verb|^>>{x}| &
    \xytree[2]{\xyconnect[->](R,L){0,1}"^>>{x}" &} &
    more \verb|>| \\
    \verb|^(.3){x}| &
    \xytree[2]{\xyconnect[->](R,L){0,1}"^(.3){x}" &} &
    30\% pos
    \\\hline
  \end{tabular}
\end{center}

Label itself is given in the curly brace (\verb+{}+).  Modification of
the label happens if the following modifier is used before
\verb+{label}+ and after modifier mark \verb+*+ is specified.
\begin{center}
  \tabcolsep3pt
  \begin{tabular}{|ll|}\hline
    \verb|+| & increase label size \\
    \verb|+<dimen>| & increase \verb|<dimen>| \\
    \verb|+=| & increase to frame size \\
    \verb|-| & decrease label size \\
    \verb|-<Å©±â>| & decrease \verb|<Å©±â>| \\
    \verb|-=| & decrease to frame size \\\hline
    \verb|!| & don't center \\\hline
    \verb|[o]| & oval \\\hline
    \verb|[l] [r] [u] [d]| & align left, right, up, down \\\hline
    \verb|[F] [F=]| & single/double line frame \\
    \verb|[F.] [F--]| & dotted/dashed line frame \\
    \verb|[F-,] [F-:<3pt>]| & shaded/rounded frame \\
    & (diameter=3pt) straight line \\\hline
  \end{tabular}
\end{center}
For example, to put rounded (\verb+[o]+) and dotted frame
(\verb+[F.]+) around the label, specify the label as follows.
\begin{verbatim}
_*[o][F.]{x}        ^*+<5pt>[o][F.]{x}
\end{verbatim}
The result is shown below.  The label with size increment is on the
left line and the one with 5pt increment on the right.

\xy
\xytree{ & \xynode{XP}
  \xyconnect{1,-1}"_*[o][F.]{x}"
  \xyconnect{1,1}"^*+<5pt>[o][F.]{x}"
  \\
  \xynode{X$'$} & & \xynode{Y}
}
\drop\frm{.}
\endxy


\subsection{\textbackslash xytext}

For agreement representation, a diagram like \ex{1} is used.
\enumsentence{%
  Morpho-syntactic agreement (AGR) can be represented as \xytext{
    \xybarnode{Det}\xybarconnect{1} & \xybarnode{head-noun} &
    \xybarnode{verb} & \xybarnode{...}}}
%
To retain the baseline and spacing on the both side of the text in
such a diagram, \verb+\xytext+ can be used instead of \verb+\xytree+.
\verb+\xytext+ requires one mandatory argument as in \ex{1}.
%
\begin{example}\label{xytext}
\begin{verbatim}
\xytext{row}
\end{verbatim}
\end{example}
The argument \verb+{row}+ is a row of content delimited by \verb+&+.

Above example \ex{-1} was typeset as follows.
\begin{verbatim}
Morpho-syntactic agreement (AGR) can
be represented as \xytext{
  \xybarnode{Det}\xybarconnect{1} &
  \xybarnode{head-noun} &
  \xybarnode{verb} & \xybarnode{...}}
\end{verbatim}
The entry in a node should be specified with \verb+\xybarnode+ command
and the arrows with \verb+\xybarconnect+.


\subsection{\textbackslash xybarnode}

As said in the previous subsection, \verb+\xybarnode+ is used for
nodes in \verb+\xytext+.  The major function of this command is to
retain the baseline of texts.

Comparing \ex{1}[a] and \ex{1}[b] makes it clearer.
%
\eenumsentence{
\item \evnup{\def\objectstyle{\hbox}%
    \xymatrix @C=0pt @M=0pt {head-noun & agreement &
      (AGR)}\hspace{-2pt}}
\item \xytext{\xybarnode{head-noun} & \xybarnode{agreement} &
    \xybarnode{(AGR)}}}
%
For the word ``agreement'' in \ex{0}[a] \verb+\xybarnode+ is not used,
but in \ex{0}[b] it is used.  In \ex{0}[a] all node are aligned with
all character on it's baseline.  In \ex{0}[b] the character \textsf{g}
in the word \textsf{agreement} displaced the whole word upwards.
\verb+\xybarnode+ command is necessary to get rid of such unwanted
displacement.


\subsection{\textbackslash xybarconnect}

Inside \verb+\xytext+ the arrow showing agreement structure is drawn
with \verb+\xybarconnect+ macro, which have the following general
syntax as in \ex{1}.
%
\begin{example}\label{xybarconnect}
\begin{verbatim}
\xybarconnect
        [spacing]
        [line art]
        (start pos, end pos)
        {target node}
        "line label"
\end{verbatim}
\end{example}
%
\verb+[spacing]+ is the first optional argument.  It is used to set
spacing between text and horizontal line.  A real number specifies the
spacing in unit of \textsf{pt}.  The default is \textsf{3}.
\begin{center}
\begin{tabular}{|ll|}\hline
  \verb|[2]| & \rule{0pt}{20pt}
  \xytext{\xybarnode{agreement}\xybarconnect[2]{1} & \xybarnode{problem}} \\
  \verb|[3]|(default) &
  \xytext{\xybarnode{agreement}\xybarconnect{1} & \xybarnode{problem}} \\
  \verb|[4]| &
  \xytext{\xybarnode{agreement}\xybarconnect[4]{1} & \xybarnode{problem}} \\\hline
\end{tabular}
\end{center}
The shape of the line can be specified with the second optional
argument \texttt{[line art]}.  All the line shapes explained in the
subsection \ref{subsection:xyconnect} can be used here too.  The
default one is a straight line with arrow head (\verb+[->]+).

\hfil
\xytext{\xybarnode{agreement}
  \xybarconnect(UL,UL){2}
  \xybarconnect[4][--]{2}
  \xybarconnect[5][.](UR,UR){2}
  &
  \xybarnode{phenomena}
  \xybarconnect[3][=](D,D){1}
  &
  \xybarnode{problem}
\POS "1,1"+UL+(-3,8);\POS "1,3"+UR+(3,8) **\dir{.}
\POS "1,1"+UL+(-3,8);\POS "1,1"+DL+(-3,-6) **\dir{.}
\POS "1,3"+UR+(3,8);\POS "1,3"+DR+(3,-6) **\dir{.}
\POS "1,1"+DL+(-3,-6);\POS "1,3"+DR+(3,-6) **\dir{.}
}

\noindent
As explained in subsection \ref{subsection:xyconnect}, the corner
position of the source and target node can be specified with the
optional argument \texttt{(start pos, end pos)}.
  
\begin{center}
\begin{tabular}{|ll|}\hline
  \verb|(U,U)|(default) & \rule{0pt}{25pt}
  \xytext{\xybarnode{agreement}\xybarconnect(U,U){1} &
    \xybarnode{problem}} \\
  \verb|(UR,UL)| & \rule{0pt}{0pt}
  \xytext{\xybarnode{agreement}\xybarconnect(UR,UL){1} &
    \xybarnode{problem}} \\
  \verb|(DL,DR)| & \raisebox{-20pt}{\rule{0pt}{0pt}}
  \xytext{\xybarnode{agreement}\xybarconnect(DL,DR){1} &
    \xybarnode{problem}} \\\hline
\end{tabular}
\end{center}

\noindent
The only mandatory argument \verb|{target node}| in this command is
used to specify the relative position number of target node from the
current node.
\begin{center}
\begin{tabular}{|ll|}\hline
  \verb|{1}| & \rule{0pt}{25pt}
  \xytext{\xybarnode{agr}\drop\frm{.}
    \xybarconnect{1}
    & \xybarnode{phenomena}\drop\frm{-} &
    \xybarnode{problem} & \xybarnode{solving}}\\[5pt]
  \verb|{2}| &
  \xytext{\xybarnode{agr}\drop\frm{.}
    \xybarconnect{2}
    & \xybarnode{phenomena} &
    \xybarnode{problem}\drop\frm{-} & \xybarnode{solving}}\\[5pt]
  \verb|{3}| &
  \xytext{\xybarnode{agr}\drop\frm{.}
    \xybarconnect{3}
    & \xybarnode{phenomena} &
    \xybarnode{problem} & \xybarnode{solving}\drop\frm{-}}\\[5pt]
  \verb|{-1}| &
  \xytext{\xybarnode{agr} & \xybarnode{phenomena} &
    \xybarnode{problem}\drop\frm{-} & \xybarnode{solving}\drop\frm{.}
    \xybarconnect{-1}}\\[5pt]
  \verb|{-2}| &
  \xytext{\xybarnode{agr} & \xybarnode{phenomena}\drop\frm{-} &
    \xybarnode{problem} & \xybarnode{solving}\drop\frm{.}
    \xybarconnect{-2}}\\[5pt]
  \verb|{-3}| & \raisebox{-10pt}{}
  \xytext{\xybarnode{agr}\drop\frm{-} & \xybarnode{phenomena} &
    \xybarnode{problem} & \xybarnode{solving}\drop\frm{.}
    \xybarconnect{-3}}\\\hline
\end{tabular}
\end{center}

\noindent
\texttt{"line label"}, if given, is placed in the middle of connection
line.  \texttt{line label} should be typeset with leading \verb|_| or
\verb|^| and in curly brace.  The directionality is the same as
explained in subsection \ref{subsection:xyconnect}.


\subsection{\textbackslash yytree}
\label{subsection:yytree}

Although not requested by linguists, there is an another tree drawing
macro defined in this package.  \verb|\yytree| uses indentation and
connection lines to draw a hierarchical tree in horizontal direction.

The general syntax is as \ex{1}.
%
\begin{example}\label{yytree}
\begin{verbatim}
\yytree[indentation]{matrix}
\end{verbatim}
\end{example}
%
The optional argument \verb|[indentation]| is the amount of
indentation for each depth of the hierarchy.  The default is \textsf{2}
in unit of \textsf{pc}.  The mandatory argument \verb|{matrix}| is the
content of horizontal hierarchical tree.  Unlikely \verb|\xytree| only
one node per a row should be defined in \verb|\yytree|.

\xy
\yytree{
  \yynode[1,4]{grandparent} \\
  & \yynode[1,2]{parent} \\
  & & \yynode{me} \\
  & & \yynode{sister} \\
  & \yynode[1]{uncle \& aunt} \\
  & & \yynode{cousin}}
\drop\frm{.}
\endxy


\subsection{\textbackslash yynode}
\label{subsection:yynode}

\verb|\yynode| specifies a node in \verb|\yytree| command.  The general
syntax is as \ex{1}.
%
\begin{example}\label{yynode}
\begin{verbatim}
\yynode[target node #]{node}
\end{verbatim}
\end{example}
%
The optional argument \texttt{[target node \#]} is comma-separated row
numbers, to which a connection line is drawn.  As usual, the number is
counted relatively to the current node.  E.g. \texttt{1} denotes the
row below current node and \texttt{2} the second row below current
node.

The tree in subsection \ref{subsection:yytree} is typeset as follows.
\begin{verbatim}
\yytree{
  \yynode[1,4]{grandparent} \\
  & \yynode[1,2]{parent} \\
  & & \yynode{me} \\
  & & \yynode{sister} \\
  & \yynode[1]{uncle \& aunt} \\
  & & \yynode{cousin}}
\end{verbatim}
The \verb|[1,4]| of the node \textsf{grandparent} for example connects
to the row \textsf{parent} directly under the current node and to the
fifth row \textsf{uncle \& aunt} (fourth row from the current node)
with a line.


\subsection{\textbackslash xynodefont}
\label{subsection:xynodefont}

This command sets the global font used in the nodes of \verb|\xytree|
and \verb|\yytree|.
%
\begin{example}\label{xynodefont}
\begin{verbatim}
\xynodefont{font spec}
\end{verbatim}
\end{example}
%
For \texttt{font spec}, font changing commands are used.  For example,
the following command typesets all nodes with italic and bold face
font as shown in the diagram below.
\begin{verbatim}
\xynodefont{\itshape\bfseries}
\end{verbatim}

\begingroup
\xy
\xynodefont{\itshape\bfseries}
\xytree[1]{
  & & \xynode[-1,1]{grandparent} \\
  & \xynode[-1,1]{parent} & & \xynode[0]{uncle \& aunt} \\
  \xynode{me} & & \xynode{sister} & \xynode{cousin}}
\drop\frm{.}
\endxy
\endgroup

This command affects all the node that appear after this declaration,
except the node, which are set with the command \verb|\xyterminal|.


\section{Useful macros from \texorpdfstring{\Xy-pic}{Xy-pic}}

The commands from \Xy-pic package can be directly used with
\textsf{xytree.sty} to draw complicated trees.  In this section, some
useful commands from \namecite{rose99:_xy_guide} are illustrated.


\subsection{Frame around node}

To enclose a node or tree in a frame, \verb|\drop| \verb|\frm| after
the \verb|\xynode| as shown in \ex{1}.
\begin{example}\label{dropframe}
\begin{verbatim}
  \drop\frm{line art}
\end{verbatim}
\end{example}
\verb|{.}|, \verb|{-}|, \verb|{=}|, \verb|{--}|,
\verb|{==}|, \verb|{o-}| can be used for \verb|{line art}|.
\verb|{o-}| drops rounded frame, whereas others do not.  Though, by
specifying diameter for the corners as in \ex{1}, the others can have
also rounded corners.
\begin{example}
\begin{verbatim}
  \drop\frm<diameter>{line art}
\end{verbatim}
\end{example}

If \verb+,+ follows \texttt{line art}, a shadow effect happens.  For
example, \verb+{,}+ draws a shadowed frame without surrounding line
and \verb+{-,}+ shadowed frame with straight line.  The thickness of
the shadow can be set as in \ex{1}.
\begin{example}
\begin{verbatim}
\drop\frm<thickness>{,}
\end{verbatim}
\end{example}

For a circled or oval frame, set \verb+{line art}+ as \verb+{o}+
or \verb+{e}+ respectively.  \verb+{oo}+ or \verb+{ee}+ doubles the
frame line.  The general syntax is shown in \ex{1}.
\begin{example}
\begin{verbatim}
\drop\frm<diameter>{shape}
\end{verbatim}
\end{example}
In case of circled frame, \verb+<diameter>+ sets the diameter of the
circle.  In case of oval frame, \verb+<diameter>+ sets two
comma-separated diameters of the major and minor axis (in the order of
$x$ and $y$ axis).

The examples for frame commands follow.

\hfil\xy\rowheight1.5pc
\xytree[3]{
  \xynode{\texttt{\{\}}}
  \drop\frm{}
  & \xynode{\texttt{\{.\}}}
  \drop\frm{.}
  & \xynode{\texttt{$<$44pt$>$\{.\}}}
  \drop\frm<44pt>{.}
  \\
  \xynode{\texttt{\{-\}}}
  \drop\frm{-}
  & \xynode{\texttt{$<$8pt$>$\{-\}}}
  \drop\frm<8pt>{-}
  & \xynode{\texttt{$<$44pt$>$\{-\}}}
  \drop\frm<44pt>{-}
  \\
  \xynode{\texttt{\{=\}}}
  \drop\frm{=}
  & \xynode{\texttt{$<$8pt$>$\{=\}}}
  \drop\frm<8pt>{=}
  & \xynode{\texttt{$<$44pt$>$\{=\}}}
  \drop\frm<44pt>{=}
  \\
  \xynode{\texttt{\{--\}}}
  \drop\frm{--}
  & \xynode{\texttt{\{o-\}}}
  \drop\frm{o-}
  & \xynode{\texttt{$<$44pt$>$\{--\}}}
  \drop\frm<44pt>{--}
  \\
  \xynode{\texttt{\{,\}}}
  \drop\frm{,}
  & \xynode{\texttt{$<$5pt$>$\{,\}}}
  \drop\frm<5pt>{,}
  & \xynode{\texttt{\{-,\}}}
  \drop\frm{-,}
  \\
  \xynode{\texttt{\{o\}}}
  \drop\frm{o}
  & \xynode{\texttt{$<$8pt$>$\{o\}}}
  \drop\frm<8pt>{o}
  & \xynode{\texttt{\{.o\}}}
  \drop\frm{.o}
  \\
  \xynode{\texttt{\{oo\}}}
  \drop\frm{oo}
  & \xynode{\texttt{$<$8pt$>$\{oo\}}}
  \drop\frm<8pt>{oo}
  & \xynode{\texttt{\{-o\}}}
  \drop\frm{-o}
  \\
  \xynode{\texttt{\{e\}}}
  \drop\frm{e}
  & \xynode{\texttt{$<$20pt,8pt$>$\{e\}}}
  \drop\frm<20pt,8pt>{e}
  & \xynode{\texttt{\{.e\}}}
  \drop\frm{.e}
  \\
  \xynode{\texttt{\{ee\}}}
  \drop\frm{ee}
  & \xynode{\texttt{$<$20pt,8pt$>$\{ee\}}}
  \drop\frm<20pt,8pt>{ee}
  & \xynode{\texttt{\{-e\}}}
  \drop\frm{-e}
  \\
}
\drop\frm{--}
\endxy

If the framing of node applies to the tree as a whole, enclose the
whole tree in between \verb+\xy+ and \verb+\endxy+.
\begin{example}
\begin{verbatim}
\xy
  \xytree{node matrix}
  \drop\frm{shape}
\endxy
\end{verbatim}
\end{example}
The following example shows the effect of dashed frame
(\verb+\drop\frm{--}+) with shadow (\verb+\drop\frm<3pt>{,}+

\hfil\xy
\xytree{
  & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}
}
\drop\frm{--}
\drop\frm<3pt>{,}
\endxy


\subsection{Extensible braces for nodes}

The usual extensible braces in \LaTeX{} are more optimized in
\Xy-pic.  The general syntax is as \ex{1}.
\begin{example}
\begin{verbatim}
\drop\frm{brace}
\end{verbatim}
\end{example}
The following \verb+{brace}+ can be used.

\medskip
\xy
\xytree[2]{
  \xynode{\begin{avm}\avml\texttt{\char123\_\ttbs\char125\char125}\\lower\avmr\end{avm}}
  \drop\frm{_\}}
  &
  \xynode{\begin{avm}\avml\texttt{\char123\^{}\ttbs\char125\char125}\\upper\avmr\end{avm}}
  \drop\frm{^\}}
  &
  \xynode{\begin{avm}\avml\texttt{\char123\ttbs\char123\char125}\\left\avmr\end{avm}}
  \drop\frm{\{}
  &
  \xynode{\begin{avm}\avml\texttt{\char123\ttbs\char125\char125}\\right\avmr\end{avm}}
  \drop\frm{\}}
  \\
  \xynode{\begin{avm}\avml\texttt{\char123\_)\char125}\\lower\avmr\end{avm}}
  \drop\frm{_)}
  &
  \xynode{\begin{avm}\avml\texttt{\char123\^{})\char125}\\upper\avmr\end{avm}}
  \drop\frm{^)}
  &
  \xynode{\begin{avm}\avml\texttt{\char123(\char125}\\left\avmr\end{avm}}
  \drop\frm{(}
  &
  \xynode{\begin{avm}\avml\texttt{\char123)\char125}\\right\avmr\end{avm}}
  \drop\frm{)}
}
\drop\frm{--}
\endxy


\subsection{Lines passing through nodes}

After the nodes in a tree are defined, it is possible to draw a line,
which passes through the nodes.  The line breaks at the node positions
automatically.

\xy
\xytree{
  & & & \xynode{S} \\
  & \xynode{NP} & & & & \xynode{VP} \\
  \xynode{Det}
  & & \xynode{N} & & \xynode{V} & & \xynode{PP}
  \ar @{->} '[-1,-1]_1 '[-2,-3]_2 '[-1,-5]|3 '[0,-6]_4 '[0,-4]_5
  '[0,-2]_6 [-1,-5]_7
}
\drop\frm{.}
\endxy

The general syntax for such construction is shown in \ex{1}.
\begin{example}
\begin{verbatim}
\ar @{line art} '[mid nodes]{label}
                ... [end node]
\end{verbatim}
\end{example}
\verb+{line art}+, \verb+{label}+, and \texttt{[mid}/\texttt{end
  node(s)]} are the same as shown in the command
\verb+\xynodeconnect+.  Note that \verb+'+ precedes the first mid
node.  All node positions are relative to the current node.  In the
above diagram the line, for example, starts from the lower-right node
\textsf{PP}.  The \textsf{NP} node, which is a mid node and end node, is typeset
as \verb+'[-1,-5]+ for the mid node, whereas as \verb+[-1,-5]+ for the
end node.


\subsection{Discourse Representation Structure}
\label{sec:drs}

The semanticists need to draw Discourse Representation Structures (DRS)
as illustrated below \cite{kamp_reyle93}:

\drsrectbox{
\drsbox{x y}{farmer(x)\\donkey(y)\\x owns y}
\drsdiabox{every\\x}
\drsbox{u}{u = y\\x beats u}
}

The difficulty resides in drawing diamond-shaped box, which is solved
with \Xy-pic module in this package.

The above diagram is coded as follows:
\begin{verbatim}
\drsrectbox{
  \drsbox{x y}{farmer(x)\\donkey(y)\\
               x owns y}
  \drsdiabox{every\\x}
  \drsbox{u}{u = y\\x beats u}
}
\end{verbatim}
For DRS, following three macros are provided.

\subsubsection{\textbackslash drsbox}
\label{sec:drsbox}

This macro draws a standard rectangular DRS box.  The syntax follows:
\begin{example}
\begin{verbatim}
\drsbox[line art]
       {referent}
       {proposition}
\end{verbatim}
\end{example}
The sort of lines can be given by the first optional argument
\texttt{[line art]} (cf.\ subsection \ref{subsection:xyconnect}).  The
referents used in the propositions will be placed in the separated
boxes as shown bellow:
\begin{example}
  \evnup{\drsbox{referents}{proposition 1\\proposition
      2\\...\\proposition n}}
\begin{verbatim}
\drsbox{referents}
       {proposition 1\\
        proposition 2\\
        ...\\
        proposition n}
\end{verbatim}
\end{example}
Each proposition is separated by \verb|\\|.

\subsubsection{\textbackslash drsrectbox}
\label{sec:drsrectbox}

This macro draws a simple rectangular box consisting of only
propositions without referents.
\begin{example}
\begin{verbatim}
\drsrectbox[line art]{proposition}
\end{verbatim}
\end{example}
The following illustrates the usage:
\begin{example}
  \evnup{\drsrectbox{proposition 1\\proposition
      2\\...\\proposition n}}
\begin{verbatim}
\drsrectbox{proposition 1\\
            proposition 2\\
            ...\\
            proposition n}
\end{verbatim}
\end{example}

\subsubsection{\textbackslash drsdiabox}
\label{sec:drsdiabox}

This macro draws a diamond-shaped box used for representing conditions
in DRS.  The syntax is shown below:
\begin{example}
\begin{verbatim}
\drsdiabox[line art]{condition}
\end{verbatim}
\end{example}
An example follows:
\begin{example}
  \evnup{\drsdiabox{condition}}
\begin{verbatim}
\drsdiabox{condition}
\end{verbatim}
\end{example}

\subsubsection{Nesting DRS boxes}
\label{sec:nestingDRS}

The boxes made by above DRS macros can be nested in each other as
shown in the following example:
\begin{example}
  \evnup{\drsbox{x}{predro(x)\\
      \drsbox{y}{donkey(y)\\own(x,y)}
      $\Rightarrow$
      \drsbox{z w}{beat(z,w)\\z=x\\w=y}}
  }
\begin{verbatim}
\drsbox{x}{predro(x)\\
  \drsbox{y}{donkey(y)\\own(x,y)}
  $\Rightarrow$
  \drsbox{z w}{beat(z,w)\\z=x\\w=y}
\end{verbatim}
\end{example}

\subsection{Autosegmental Representation}
\label{sec:asr}

Autosegmental Representation (ASR) can be drawn directly with \Xy-pic
macros with ease\footnote{Some skills in using \Xy-pic module directly
  are required to draw ASR diagrams though.}.  In principle, no
further macros need to be provided to draw ASR diagrams, but only for
convenience, a macros to align the segmental nodes horizontally is
defined in \textsf{xytree.sty}.
\begin{example}
\begin{verbatim}
\asrnode{node}
\end{verbatim}
\end{example}
This macros is identical with \texttt{\textbackslash
  txt\{\textbackslash strut \}} in \Xy-pic module.

Here is an example using this macro in drawing an ASR diagram with
\Xy-pic macros:
\begin{example}
  \evnup{\xy
<0pt,0pt>*\asrnode{k}="k",
<1em,0pt>*\asrnode{a}="a",
<2em,0pt>*\asrnode{t}="t",
<0pt,1cm>*\asrnode{$\times$}="x1",
<1em,1cm>*\asrnode{$\times$}="x2",
<2em,1cm>*\asrnode{$\times$}="x3",
<.5em,2cm>*\asrnode{$\mu$}="m1",
<2em,2cm>*\asrnode{$\mu$}="m2",
"k"+U;"x1"+D**\dir{-};
"a"+U;"x2"+D**\dir{-};
"t"+U;"x3"+D**\dir{-};
"x1"+U;"m1"+D**\dir{-};
"x2"+U;"m1"+D**\dir{-};
"x3"+U;"m2"+D**\dir{-};
\endxy}
\begin{verbatim}
\xy
<0pt,0pt>*\asrnode{k}="k",
<1em,0pt>*\asrnode{a}="a",
<2em,0pt>*\asrnode{t}="t",
<0pt,1cm>*\asrnode{$\times$}="x1",
<1em,1cm>*\asrnode{$\times$}="x2",
<2em,1cm>*\asrnode{$\times$}="x3",
<.5em,2cm>*\asrnode{$\mu$}="m1",
<2em,2cm>*\asrnode{$\mu$}="m2",
"k"+U;"x1"+D**\dir{-};
"a"+U;"x2"+D**\dir{-};
"t"+U;"x3"+D**\dir{-};
"x1"+U;"m1"+D**\dir{-};
"x2"+U;"m1"+D**\dir{-};
"x3"+U;"m2"+D**\dir{-};
\endxy
\end{verbatim}
\end{example}


\section{Notes}
\label{sec:note}

\subsection{Error message}

If a line tries to connect to an undefined node, an error occurs.  For
example, the matrix below has the size of $3\times4$.

\begingroup
\hfil\xy
\def\objectstyle{\hbox}
\xymatrix @W=2pc @H=1pc @R=0pc @C=0pc @*[F.]{
  & (1,2) & & \\
  (2,1) & & (2,3) & \\
  & (3,2) & & (3,4)
}
\drop\frm{-}
\endxy
\endgroup

\noindent
If a line tries to connect from node ``(1,2)'' to the node ``(2,4)''
with following codes
\begin{verbatim}
\xytree{
  & \xynode[2]{(1,2)} \\
  \xynode{(2,1)} & & \xynode{(2,3)} \\
  & \xynode{(3,2)} & & \xynode{(3,4)}
}
\end{verbatim}
an error occurs as follows because of the undefined node right after
the node ``(2,3)'' (the trailing empty nodes need not necessarily
defined).

\noindent
\texttt{! Xy-pic error: in entry "1,2":\\ No [1,2] (is "2,4") from
  here.}

This message says that an error occurred at the entry in the absolute
position \verb+"1,2"+ and pointing to an entry at the relative position
\verb+[1,2]+ caused an undefined entry with an absolute position
\verb+"2,4"+.

Such an error can be avoided by defining an empty entry at the
absolute position \verb+"2,4"+ if the line should be appear.  Remember
that all empty nodes at the right-side of a non-empty nodes can be
omitted.  Though, if a node somewhere in the \Xy-pic matrix point to
such an empty node, it must not be omitted.

In many cases, analyzing the error messages is helpful to find out
which of undefined target node is unintentionally accessed by a
connection line.  An example is shown below, where the error is solved
by defining an empty node.

\begin{verbatim}
\xytree{
  & \xynode[2]{(1,2)} \\
  \xynode{(2,1)} & & \xynode{(2,3)} & \\
  & \xynode{(3,2)} & & \xynode{(3,4)}
}
\end{verbatim}
\hfil\xy\rowheight1.5pc
\xytree{
  & \xynode[2]{(1,2)} \\
  \xynode{(2,1)} & & \xynode{(2,3)} & \\
  & \xynode{(3,2)} & & \xynode{(3,4)}
}
\drop\frm{.}
\endxy


\subsection{Problem in left/right alignment}
\label{subsection:alignment}

If used barely (without \verb+\xy+ and \verb+\endxy+), \verb+\xytree+
and \verb+\yytree+ don't show inconsistency in alignment with the
text, but if used inside \verb+\xy+ and \verb+\endxy+ or
\verb+\begin{xy}+ and \verb+\end{xy}+ in order to use such command as
\verb+\drop\frm+, the tree is aligned to the left side of the text as
shown below (\textsf{raggedleft} environment doesn't work).

\begin{verbatim}
\begin{raggedleft}
  \xy
    \xytree{ & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
  \endxy
\end{raggedleft}
\end{verbatim}
%
\begin{raggedleft}
  \xy
    \xytree{ & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
  \endxy
\end{raggedleft}
\noindent
This kind of error seems to happen by an internal mechanism of \Xy-pic
macros, and can be avoid by setting \verb+\hfil+ or \verb+\hfill+ in
front of \verb+\xy+ instead of using \texttt{center} or
\texttt{raggedleft} environment.

An example of using \verb+\hfil+ to align tree to the center of text
line is shown below.
\begin{verbatim}
\hfil
\xy
\xytree{ & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}}
\drop\frm{.}
\endxy
\end{verbatim}
\hfil
\xy
\xytree{ & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}}
\drop\frm{.}
\endxy

A right-justified example using \verb+\hfill+ follows.

\begin{verbatim}
\hfill
\xy
\xytree{ & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}}
\drop\frm{.}
\endxy
\end{verbatim}
\hfill
\xy
\xytree{ & \xynode[-1,1]{S} \\
  \xynode{NP} & & \xynode{VP}}
\drop\frm{.}
\endxy


\subsection{Problem in alignment within \textbackslash
  enumsentence}

This kind of bottom-aligning problem happens, when a tall object is
put inside of \verb+\enumsentence+ macro.  The \verb+\enumsentence+ or
\verb+\eenumsentence+ macro is provided by \textsf{lingmacros.sty} to
make enumerated linguistic examples.  The erroneous output looks like
as follows.  The example numbering is placed under the tree.
\begin{example}\label{misalign}
  \xy
  \xytree{ & \xynode[-1,1]{S} \\
    \xynode{NP} & & \xynode{VP}}
  \drop\frm{.}
  \endxy
\end{example}
%
Because this kind of error occurs so often with
\textsf{lingmacros.sty}, it provides an extra macro \verb+\evnup+.
See \namecite{pease00:_linguis_macros}.  An example of \verb|\evnup|
below aligns the tree correctly with the example number.

\begin{verbatim}
\enumsentence{\evnup{%
    \xy
    \xytree{
      & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
    \endxy
  }}
\end{verbatim}
\enumsentence[(\ref{misalign}$'$)]{\evnup{%
    \xy
    \xytree{
      & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
    \endxy
  }}%
Another solution would be using \verb+\leavevmode+ in front of
\verb+\xy+ to escape from vertical mode of \TeX.  An example using
this method follows.

\begin{verbatim}
\enumsentence{\leavevmode
  \xy
  \xytree{
    & \xynode[-1,1]{S} \\
    \xynode{NP} & & \xynode{VP}}
  \drop\frm{.}
  \endxy
}
\end{verbatim}
%
\enumsentence[(\ref{misalign}$''$)]{\leavevmode
  \xy
  \xytree{
    & \xynode[-1,1]{S} \\
    \xynode{NP} & & \xynode{VP}}
  \drop\frm{.}
  \endxy
}
If an example has several sub-examples, \verb+\eenumsentence+ macro is
used.  The sub-examples are introduced by \verb+\item+ command.  In
this case, all sub-examples should be individually handled with
\verb+\evnup+ or \verb+leavevmode+ command for proper alignment.  See
the following example.

\begin{verbatim}
\eenumsentence{
\item \evnup{%
    \xy
    \xytree{
      & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
    \endxy
  }
\item \leavevmode
  \xy
  \xytree{
    & \xynode[-1,1]{NP} \\
    \xynode{Det} & & \xynode{N}}
  \drop\frm{.}
  \endxy
}
\end{verbatim}
%
\eenumsentence{
\item \evnup{%
    \xy
    \xytree{
      & \xynode[-1,1]{S} \\
      \xynode{NP} & & \xynode{VP}}
    \drop\frm{.}
    \endxy
  }
\item \leavevmode
  \xy
  \xytree{
    & \xynode[-1,1]{NP} \\
    \xynode{Det} & & \xynode{N}}
  \drop\frm{.}
  \endxy
}


\section{Some examples}

\avmhskip{3pt}
\avmfont{\scshape}
\avmvalfont{\itshape}


\subsection{Tree with AVM}

% example 1
\noindent
\xy
\xytree[2.2]{
  & \xynode[-1,1]{\begin{avm}\[head & \@3 \\ subcat & \q<
      \q>\]\end{avm}} \\
  \xynode{\begin{avm}
      \[
      \@2head & \@1\\
      marking & \@4 \\
      subcat & \q< \q>
      \]
    \end{avm}} & & \xynode{\begin{avm}
      \[
      head\@3 & \[
                pos & V[-A] \\
                vform & da
                \] \\
      subcat & \q< \@2 \q>
      \]
    \end{avm}}
}
\drop\frm{.}
\endxy

\begin{verbatim}
\xytree[2.2]{
  & \xynode[-1,1]{\begin{avm}
      \[
      head & \@3 \\
      subcat & \q< \q>
      \]
    \end{avm}} \\
  \xynode{\begin{avm}
      \[
      \@2head & \@1\\
      marking & \@4 \\
      subcat & \q< \q>
      \]
    \end{avm}} & & \xynode{\begin{avm}
      \[
      head\@3 & \[
                pos & V[-A] \\
                vform & da
                \] \\
      subcat & \q< \@2 \q>
      \]
    \end{avm}}
}
\end{verbatim}
\noindent
The overall structuring of the tree can be simplified as follows.
\begin{verbatim}
\xytree[2.2]{ & \xynode[-1,1]{AVM} \\
  \xynode{AVM} & & \xynode{AVM}
}
\end{verbatim}
\noindent
The connection lines of nodes start from the node in the first row
(\verb+[-1,1]+), \verb+-1+ connects to the first node in the second
row, and \verb+1+ connects to the second node in the second row.  Each
node is typeset using \texttt{avm} environment provided by
\textsf{avm.sty}.


\subsection{Multiple daughter node}

% example 2
\xy
\xytree{
  & & & & \xynode[-2,2]{pernum} \\
  & & \xynode[-2,-1,0,1,2]{non3sg} & & & & \xynode{3sg} \\
  \xynode{1sg} & \xynode{1pl} & \xynode{2sg} & \xynode{2pl} & \xynode{3pl}
}
\drop\frm{.}
\endxy

\bigskip
\begin{verbatim}
\xytree{
  & & & & \xynode[-2,2]{pernum} \\
  & & \xynode[-2,-1,0,1,2]{non3sg} & & &
  & \xynode{3sg} \\
  \xynode{1sg} & \xynode{1pl}
  & \xynode{2sg} & \xynode{2pl}
  & \xynode{3pl}
}
\end{verbatim}
\noindent
% explanation
At first, all node positions are fixed.  \textsf{pernum} is placed at
the fifth cell of the first row, \textsf{nonsg} third cell of the
second row, \textsf{3sg} seventh cell of the second row, and so on.
The line from the node \textsf{pernum} connects to the second node
leftwards and second node rightwards in the row below, all relatively
(\verb+[-2,2]+).  The five daughter nodes of \textsf{non3sg} is placed
from the first cell in the third row.  The connection lines are coded
as \verb+[-2,-1,0,1,2]+.


\subsection{Special connection line}

% example 3
\xy
\xytree{
  & \xynode[-1,1]{Agr$_s$P} \\
  \xynode{NP}
  \xyconnect[--][_.7pc](D,L){1,1}
  & & \xynode[-1,1]{Agr$_{s}^{'}$} \\
  & \xynode{Agr$_s$}
  \xyconnect[--][_2pc](D,L){2,2}
  & & \xynode[-1,1]{...} \\
  & & \xynode{..} & & \xynode[-1,1]{VP} \\
  & & & \xynode{V} & & \xynode{...}
}
\drop\frm{.}
\endxy

\begin{verbatim}
\xytree{
  & \xynode[-1,1]{Agr$_s$P} \\
  \xynode{NP}
  \xyconnect[--][_.7pc](D,L){1,1}
  & & \xynode[-1,1]{Agr$_{s}^{'}$} \\
  & \xynode{Agr$_s$}
  \xyconnect[--][_2pc](D,L){2,2}
  & & \xynode[-1,1]{...} \\
  & & \xynode{..} & & \xynode[-1,1]{VP} \\
  & & & \xynode{V} & & \xynode{...}
}
\end{verbatim}
\noindent
Specifying and connecting nodes with lines are the basic task in
drawing trees.  In order to draw dash lines, \verb+\xycoonect+ macro
is used.\\
\verb|\xyconnect[--][_.7pc](D,L){2,2}|\\
This is the dash line connecting node \textsf{NP} and
\textsf{Agr$_s$}.  The second optional argument is given as
\verb+[_.7pc]+, which specifies the amount of inflection of the dash
line.  The direction of the dash line is from left to right, so the
dash line inflects downwards (\verb+_+).  Because node
\textsf{Agr$_s$} and \textsf{V} are placed more far away than node
\textsf{NP} and \textsf{Agr$_s$}, the amount of inflection of the dash
line is given by more larger value of \verb+[_2pc]+.


\subsection{Dependency diagram}

% example 4
\xytext{
  \xybarnode{V}
  \xybarconnect[3][-](D,DL){2}"|{R}"
  \xybarconnect[6][-](D,D){2}"|{R}"
  & \xybarnode{\qquad}
  & \xybarnode{(DP$_1-\alpha$ DP$_2-\alpha$)}
\POS "1,1"+UL;\POS "1,3"+UR **\dir{.}
\POS "1,1"+UL;\POS "1,1"+DL+(0,-8) **\dir{.}
\POS "1,3"+UR;\POS "1,3"+DR+(0,-8) **\dir{.}
\POS "1,1"+DL+(0,-8);\POS "1,3"+DR+(0,-8) **\dir{.}
}

\noindent
% code:
\begin{verbatim}
\xytext{
  \xybarnode{V}
  \xybarconnect[3][-](D,DL){2}"|{R}"
  \xybarconnect[6][-](D,D){2}"|{R}"
  & \xybarnode{\qquad}
  & \xybarnode{(DP$_1-\alpha$ %
                DP$_2-\alpha$)
}
\end{verbatim}

\noindent
Three nodes are specified.  Second and third node are connected with
line from the first node.  Breaking the connection line, the labels
are placed in the middle.


\section{Summary}

In this manual, many macros for drawing syntactic trees for
linguistics are explained.  A tree is constructed with a
\verb+\xytree+ command.  It is advisable to analyze the tree structure
in a lattice structure.  A simple tree could be completed using only
\verb+\xynode+ commands by connecting nodes with it's optional
argument.  If a tree has more or less complicated lines,
\verb+\xyconnect+ command can be used.

For agreement structure, \verb+\xytext+ is used.  In this case
\verb+\xybarnode+ is used to specify nodes and \verb+\xybarconnect+ is
used for the connection lines.

The commands provided by \Xy-pic package can also be used to draw very
complicated trees.  Some frequently encountered errors and a possible
solutions are also treated in this manual.

As an extension for semanticists, \verb+\drsbox+, \verb+\drsrectbox+,
\verb+\drsdiabox+ are added to \textsf{xytree.sty} for drawing DRS
diagrams.  One could also use \Xy-pic macros directly to draw ASR
diagrams.  In this case, \verb+\asrnode+ could be used efficiently.

With \textsf{xytree.sty}, it is relatively easy to draw linguistic
syntactic trees.  For more question concerning this package, please
mail me (\url{mailto:koaunghi@kornet.net}).

\bibliographystyle{fullname}
\bibliography{xytree}

\end{multicols}

\end{document}

% LocalWords:  xytree pic parsetree dvips Pease PostScript xdvi PDF pdflatex xy
% LocalWords:  dvi pc Det AVM pease xynode xytrinode xyterminal xyconnect pos
% LocalWords:  DL Koaunghi Un XP AGR agr