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
|
%% BEGIN psd-node.tex
\part{Nodes and Node Connections\label{P-nodes}}
% This is a file marker for pst-node (e.g., \File{pst-node}), defined as a node:
\leavevmode
\marginpar{%
\leavevmode\lower 20pt\hbox{%
\hbox to0pt{\hbox to \linewidth{\hss\rnode{file}{\copy\filebox}\hss}\hss}%
\raise 10pt\hbox to \linewidth{\hss\large\bfseries\sffamily pst-node\hss}}}%
All the commands described in this part are contained in the file
"pst-node.tex" / "pst-node.sty".
The node and node connection macros let you connect information and place
labels, without knowing the exact position of what you are connecting or of
where the lines should connect. These macros are useful for making graphs and
trees, mathematical diagrams, linguistic syntax diagrams, and connecting ideas
of any kind. They are the trickiest tricks in PSTricks!
The node and node connection macros let you connect information and place
labels, without knowing the exact position of what you are connecting or where
the lines should connect. These macros are useful for making graphs and trees,
mathematical diagrams, linguistic syntax diagrams, and connecting ideas of any
kind. They are the trickiest tricks in PSTricks!
There are three components to the node macros:
\begin{description}
\item[Node definitions] The node definitions let you assign a name and shape
to an object. See Section \ref{S-nodes}.
\item[Node connections] The node connections connect two nodes, identified
by their names. See Section \ref{S-nc}.
\item[Node labels] The node label commands let you affix labels to the node
connections. See Section \ref{S-nodelabels}.
\end{description}
You can use these macros just about anywhere. The best way to position them
depends on the application. For greatest flexibility, you can use the nodes in
a \n\pspicture, positioning and rotating them with \n\rput. You can also use
them in alignment environments. "pst-node.tex" contains a special alignment
environment, \n\psmatrix, which is designed for positioning nodes in a grid,
such as in mathematical diagrams and some graphs. \n\psmatrix{} is described in
Section \ref{S-psmatrix}. "pst-node.tex" also contains high-level macros for
trees. These are described in Part \ref{P-trees}.
But don't restrict yourself to these more obvious uses. For example:
\begin{example**}
\rnode{A}{%
\parbox{4cm}{\raggedright
I made the file symbol a node. Now I can draw an
arrow so that you know what I am talking about.}}
\ncarc[nodesep=8pt]{->}{A}{file}
\end{example**}
\Section{Nodes\label{S-nodes}}
Nodes have a name. a boundary and a center.
\begin{Warning}
The name is for refering to the node when making node connections and labels.
You specify the name as an argument to the node commands. The name must
contain only letters and numbers, and must begin with a letter. Bad node names
can cause PostScript errors.
\end{Warning}
The center of a node is where node connections point to. The boundary is for
determining where to connect a node connection. The various nodes differ in
how they determine the center and boundary. They also differ in what kind of
visable object they create.
Here are the nodes:
\begin{description}
\mitem \rnode`[refpoint]'{name}{stuff}
\n\rnode{} puts <stuff> in a box. The center of the node is <refpoint>, which
you can specify the same way as for \n\rput.
\oitem \Rnode{name}{stuff}
\n\Rnode{} also makes a box, but the center is set differently. If you align
\n\rnode's by their baseline, differences in the height and depth of the nodes
can cause connecting lines to be not quite parallel, such as in the following
example:
\begin{example**}
\Large
\rnode{A}{sp} \hskip 2cm \rnode{B}{Bit}
\ncline{A}{B}
\end{example**}
With \n\Rnode, the center is determined relative to the baseline:
\begin{example**}
\Large
\Rnode{A}{sp} \hskip 2cm \Rnode{B}{Bit}
\ncline{A}{B}
\end{example**}
You can usually get by without fiddling with the center of the node, but to
modify it you set the
\begin{Ex}
\Par{href=num}
\Par{vref=dim}
\end{Ex}
parameters. In the horizontal direction, the center is located fraction
\p{href} from the center to the edge. E.g, if \p{href=-1}, the center is on
the left edge of the box. In the vertical direction, the center is located
distance \p{vref} from the baseline. The \p{vref} parameter is evaluated each
time \n\Rnode{} is used, so that you can use "ex" units to have the distance
adjust itself to the size of the current font (but without being sensitive to
differences in the size of letters within the current font).
\mitem \pnode`\c~'{name}
This creates a zero dimensional node at \c{}.
\oitem \cnode`\c~'{radius}{name}
This draws a circle. Here is an example with \n\pnode{} and \n\cnode:
\begin{MEx}(3,1.25)
\cnode(0,1){.25}{A}
\pnode(3,0){B}
\ncline{<-}{A}{B}
\end{MEx}
\oitem \Cnode`\c~'{name}
This is like \n\cnode, but the radius is the value of
\begin{Ex}
\Par{radius=dim}
\end{Ex}
This is convenient when you want many circle nodes of the same radius.
\oitem \circlenode{name}{stuff}
This is a variant of \n\pscirclebox{} that gives the node the shape of the
circle.
\oitem \cnodeput`{angle}\c~'{name}{stuff}
This is a variant of \n\cput{} that gives the node the shape of the
circle. That is, it is like
\begin{LVerb*}
\rput{<angle>}(<x>,<y>){\circlenode{<name>}{<stuff>}}
\end{LVerb*}
\oitem \ovalnode{name}{stuff}
This is a variant of \n\psovalbox{} that gives the node the shape of an
ellipse. Here is an example with \n\circlenode{} and \n\ovalnode:
\begin{example**}
\circlenode{A}{Circle} and \ovalnode{B}{Oval}
\ncbar[angle=90]{A}{B}
\end{example**}
\oitem \dianode{name}{stuff}
This is like \n\diabox.
\oitem \trinode{name}{stuff}
This is like \n\tribox.
\begin{MEx}(4,3)
\rput[tl](0,3){\dianode{A}{Diamond}}
\rput[br](4,0){\trinode[trimode=L]{B}{Triangle}}
\nccurve[angleA=-135,angleB=90]{A}{B}
\end{MEx}
\oitem \dotnode`\c~'{name}
This is a variant of \n\psdot. For example:
\begin{MEx}(3,2)
\dotnode[dotstyle=triangle*,dotscale=2 1](0,0){A}
\dotnode[dotstyle=+](3,2){B}
\ncline[nodesep=3pt]{A}{B}
\end{MEx}
\oitem \fnode`\c~'{name}
The "f" stands for ``frame''. This is like, but easier than, putting a
\n\psframe{} in an \n\rnode.
\begin{MEx}(3,2)
\fnode{A}
\fnode*[framesize=1 5pt](2,2){B}
\ncline[nodesep=3pt]{A}{B}
\end{MEx}
There are two differences between \n\fnode{} and \n\psframe:
\begin{itemize}
\item There is a single (optional) coordinate argument, that gives the
\emph{center} of the frame.
\item The width and height of the frame are set by the
\begin{Ex}
\Par{framesize=dim1 `dim2'}
\end{Ex}
parameter. If you omit <dim2>, you get a square frame.
\end{itemize}
\end{description}
\Section{Node connections\label{S-nc}}
All the node connection commands begin with "nc", and they all have the same
syntax:\footnote{%
The node connections can be used with \n\pscustom. The beginning of the node
connection is attached to the current point by a straight line, as with
\n\psarc.}$^,$\footnote{%
See page \protect\pageref{S-SpecialCoor} if you want to use the nodes as
coordinates in other PSTricks macros.}
\begin{LVerb*}
\<nodeconnection>[<par>]{<arrows>}{<nodeA>}{<nodeB>}
\end{LVerb*}
A line of some sort is drawn from <nodeA> to <nodeB>. Some of the node
connection commands are a little confusing, but with a little experimentation
you will figure them out, and you will be amazed at the things you can do.
When we refer to the "A" and "B" nodes below, we are referring only to the
order in which the names are given as arguments to the node connection
macros.\footnote{%
When a node name cannot be found on the same page as the node connection
command, you get either no node connection or a nonsense node connection.
However, \TeX{} will not report any errors.}
The node connections use many of the usual graphics parameters, plus a few
special ones. Let's start with one that applies to all the node connections:
\begin{Ex}
\Par{nodesep=dim}
\end{Ex}
\p{nodesep} is the border around the nodes that is added for the purpose of
determining where to connect the lines.
For this and other node connection parameters, you can set different values
for the two ends of the node connection. Set the parameter \p{nodesepA} for
the first node, and set \p{nodesepB} for the second node.
The first two node connections draw a line or arc directly between the two
nodes:
\begin{description}
\oitem \ncline`{arrows}'{nodeA}{nodeB}
This draws a straight line between the nodes. For example:
\begin{MEx}(4,3)
\rput[bl](0,0){\rnode{A}{Idea 1}}
\rput[tr](4,3){\rnode{B}{Idea 2}}
\ncline[nodesep=3pt]{<->}{A}{B}
\end{MEx}
\oitem \ncarc`{arrows}'{nodeA}{nodeB}
This connects the two nodes with an arc.
\begin{MEx}[-.5,-.5](3.5,2.5)
\cnodeput(0,0){A}{X}
\cnodeput(3,2){B}{Y}
\psset{nodesep=3pt}
\ncarc{->}{A}{B}
\ncarc{->}{B}{A}
\end{MEx}
The angle between the arc and the line between the two nodes is\footnote{%
Rather than using a true arc, \n\ncarc{} actually draws a bezier curve. When
connecting two circular nodes using the default parameter values, the curve
will be indistinguishable from a true arc. However, \n\ncarc{} is more
flexible than an arc, and works right connecting nodes of different shapes and
sizes. You can set \p{arcangleA} and \p{arcangleB} separately, and you can
control the curvature with the \p{ncurv} parameter, which is described on page
\pageref{p+ncurv}.}
\begin{Ex}
\Par{arcangle=angle}
\end{Ex}
\end{description}
\n\ncline{} and \n\ncarc{} both determine the angle at which the node
connections join by the relative position of the two nodes. With the next
group of node connections, you specify one or both of the angles in absolute
terms, by setting the
\begin{Ex}
\Par{angle=angle}
\end{Ex}
(and \p{angleA} and \p{angleB}) parameter.
You also specify the length of the line segment where the node connection
joins at one or both of the ends (the ``arms'') by setting the
\begin{Ex}
\Par{arm=dim}
\end{Ex}
(and \p{armA} and \p{armB}) parameter.
These node connections all consist of several line segments, including the
arms. The value of \p{linearc} is used for rounding the corners.
Here they are, starting with the simplest one:
\begin{description}
\oitem \ncdiag`{arrows}'{nodeA}{nodeB}
An arm is drawn at each node, joining at angle \p{angleA} or \p{angleB},
and with a length of \p{armA} or \p{armB}. Then the two arms are connected
by a straight line, so that the whole line has three line segments.
For example:
\begin{MEx}(4,3)
\rput[tl](0,3){\rnode{A}{\psframebox{Node A}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncdiag[angleA=-90, angleB=90, arm=.5, linearc=.2]{A}{B}
\end{MEx}
You can also set one or both of the arms to zero length. For example, if you
set \p{arm=0}, the nodes are connected by a straight line, but you get to
determine where the line connects (whereas the connection point is determined
automatically by \n\ncline). Compare this use of \n\ncdiag{} with \n\ncline{}
in the following example:
\begin{MEx}[0,-.5](4,2.5)
\rput[r](4,1){\ovalnode{R}{Root}}
\cnodeput(1,2){A}{XX}
\cnodeput(1,0){B}{YY}
\ncdiag[angleB=180, arm=0]{<-}{A}{R}
\ncline{<-}{B}{R}
\end{MEx}
(Note that in this example, the default value \p{angleA=0} is used.)
\oitem \ncdiagg`{arrows}'{nodeA}{nodeB}
\n\ncdiagg{} is similar to \n\ncdiag, but only the arm for node A is drawn.
The end of this arm is then connected directly to node B. Compare
\n\ncdiagg{} with \n\ncdiag{} when \p{armB=0}:
\begin{MEx}[-.5,-1](3.5,1)
\cnode(0,0){12pt}{a}
\rput[l](3,1){\rnode{b}{H}}
\rput[l](3,-1){\rnode{c}{T}}
\ncdiagg[angleA=180, armA=1.5, nodesepA=3pt]{b}{a}
"\nbput[npos=1.2]{\texttt{\string\ncdiagg}}
\ncdiag[angleA=180, armA=1.5, armB=0, nodesepA=3pt]{c}{a}
"\naput[npos=1.2]{\texttt{\string\ncdiag}}
\end{MEx}
You can use \n\ncdiagg{} with \p{armA=0} if you want a straight line that
joins to node A at the angle you specify, and to node B at an angle that is
determined automatically.
\oitem \ncbar`{arrows}'{nodeA}{nodeB}
This node connection consists of a line with arms dropping ``down'', at
right angles, to meet two nodes at an angle \p{angleA}. Each arm is at least
of length \p{armA} or \p{armB}, but one may be need to be longer.
\begin{example**}
\rnode{A}{Connect} some \rnode{B}{words}!
\ncbar[nodesep=3pt,angle=-90]{<-**}{A}{B}
\ncbar[nodesep=3pt,angle=70]{A}{B}
\end{example**}
Generally, the whole line has three straight segments.
\oitem \ncangle`{arrows}'{nodeA}{nodeB}
Now we get to a more complicated node connection. \n\ncangle{} typically
draws three line segments, like \n\ncdiag. However, rather than fixing the
length of arm A, we adjust arm A so that the line joining the two arms meets
arm A at a right angle. For example:
\begin{MEx}(4,3)
\rput[tl](0,3){\rnode{A}{\psframebox{Node A}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncangle[angleA=-90,angleB=90,armB=1cm]{A}{B}
\end{MEx}
Now watch what happens when we change \p{angleA}:
\begin{MEx}(4,3)
\rput[tl](0,3){\rnode{A}{\psframebox{Node A}}}
"\nput[labelsep=0]{-70}{A}{%
" \psarcn(0,0){.4cm}{0}{-70}
" \uput{.4cm}[-35](0,0){\texttt{angleA}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncangle[angleA=-70,angleB=90,armB=1cm,linewidth=1.2pt]{A}{B}
"\nput[labelsep=0]{90}{B}{%
" \rput[bl](2pt,1pt){%
" \valign{%
" \vfil#\vfil\cr
" \hbox{\psscaleboxto(.3,.95cm){\}}}\cr%
" \hbox{\kern 1pt{\texttt{armB}}}\cr}}}
"\ncput[nrot=:U,npos=1]{\psframe[dimen=middle](0,0)(.35,.35)}
\end{MEx}
\n\ncangle{} is also a good way to join nodes by a right angle, with just two
line segments, as in this example:
\begin{MEx}(4,2)
\rput[tl](0,2){\rnode{A}{\psframebox{Node A}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncangle[angleB=90, armB=0, linearc=.5]{A}{B}
\end{MEx}
\oitem \ncangles`{arrows}'{nodeA}{nodeB}
\n\ncangles{} is similar to \n\ncangle, but the length of arm A is fixed by
he \p{armA} parameter. Arm A is connected to arm B by two line segments that
eet arm A and each other at right angles. The angle at which they join arm B,
and the length of the connecting segments, depends on the positions of the two
arms. \n\ncangles{} generally draws a total of four line segments.\footnote{%
Hence there is one more angle than \n\ncangle, and hence the "s" in
\n\ncangles.}
For example:
\begin{MEx}(4,4)
\rput[tl](0,4){\rnode{A}{\psframebox{Node A}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncangles[angleA=-90, armA=1cm, armB=.5cm, linearc=.15]{A}{B}
\end{MEx}
Let's see what happens to the previous example when we change \p{angleB}:
\begin{MEx}(4,4)
\rput[tl](0,4){\rnode{A}{\psframebox{Node A}}}
\rput[br](4,0){\ovalnode{B}{Node B}}
\ncangles[angleA=-90, angleB=135, armA=1cm, armB=.5cm,
linearc=.15]{A}{B}
"\nput[labelsep=0]{-90}{A}{%
" \psarcn(0,0){.4cm}{0}{-90}
" \uput{.4cm}[-45](0,0){\texttt{angleA}}
" \rput[tr](-2pt,0){%
" \valign{%
" \vfil#\vfil\cr
" \hbox{\texttt{armA}\kern 1pt}\cr
" \hbox{\psscaleboxto(.28,.95cm){\{}}\cr%
" \cr}}}
"\nput[labelsep=0]{135}{B}{%
" \psarc(0,0){.4cm}{0}{133}
" \uput{.4cm}[50.5](0,0){\texttt{angleB}}
" }
"\ncput[nrot=:L,npos=2]{\psline(0,-.35)(-.35,-.35)(-.35,0)}
"\ncput[npos=3.5]{%
" \rput[r](-.8,0){\rnode{arm}{\texttt{armB}}}
" \pnode{brak}}%
"\ncline[nodesep=3pt]{->}{arm}{brak}
\end{MEx}
\oitem \ncloop`{arrows}'{nodeA}{nodeB}
\n\ncloop{} is also in the same family as \n\ncangle{} and \n\ncangles, but
now typically 5 line segments are drawn. Hence, \n\ncloop{} can reach around
to opposite sides of the nodes. The lengths of the arms are fixed by \p{armA}
and \p{armB}. Starting at arm A, \n\ncloop{} makes a 90 degree turn to the
left, drawing a segment of length
\begin{Ex}
\Par{loopsize=dim}
\end{Ex}
This segment connects to arm B the way arm A connects to arm B with \n\ncline;
that is, two more segments are drawn, which join the first segment and each
other at right angles, and then join arm B. For example:
\begin{example**}
"\vrule width 0pt height 1cm
\rnode{a}{\psframebox{\Huge A loop}}
\ncloop[angleB=180,loopsize=1,arm=.5,linearc=.2]{->}{a}{a}
"\ncput[npos=3.5,nrot=:U]{\psline{|<->|}(.5,-.2)(-.5,-.2)}
"\nbput[npos=3.5,nrot=:D,labelsep=.35cm]{{\tt loopsize}}
"\kern .5cm
\end{example**}
In this example, node A and node B are the same node! You can do this with all
the node connections (but it doesn't always make sense).
Here is an example where \n\ncloop{} connects two different nodes:
\begin{example**}
\parbox{3cm}{%
\rnode{A}{\psframebox{\large\textbf{Begin}}}
\vspace{1cm}\hspace*{\fill}
\rnode{B}{\psframebox{\large\textbf{End}}}
\ncloop[angleA=180,loopsize=.9,arm=.5,linearc=.2]{->}{A}{B}}
"\ncput[npos=1.5,nrot=:U]{\psline{|<->|}(.45,-.2)(-.45,-.2)}
"\nbput[npos=1.5,nrot=:D,labelsep=.35cm]{\texttt{loopsize}}
"\kern .5cm
\end{example**}
\end{description}
The next two node connections are a little different from the rest.
\begin{description}
\oitem \nccurve`{arrows}'{nodeA}{nodeB}
\n\nccurve{} draws a bezier curve between the nodes.
\begin{MEx}(4,3)
\rput[bl](0,0){\rnode{A}{\psframebox{Node A}}}
\rput[tr](4,3){\ovalnode{B}{Node B}}
\nccurve[angleB=180]{A}{B}
\end{MEx}
You specify the angle at which the curve joins the nodes by setting the
\p{angle} (and \p{angleA} and \p{angleB}) parameter. The distance to the
control points is set with the
\begin{Ex}
\Par{ncurv=num}
\end{Ex}
(and \p{ncurvA} and \p{ncurvB}) parameter. A lower number gives a tighter
curve. (The distance between the beginning of the arc and the first control
point is one-half \p{ncurvA} times the distance between the two endpoints.)
\oitem \nccircle`{arrows}'{node}{radius}
\n\nccircle{} draws a circle, or part of a circle, that, if complete, would
pass through the center of the node counterclockwise, at an angle of
\p{angleA}.
\begin{example**}
"\vrule width 0pt height 1.4cm
\rnode{A}{\textbf{back}}
\nccircle[nodesep=3pt]{->}{A}{.7cm}
\kern 5pt
\end{example**}
\n\nccircle{} can only connect a node to itself; it is the only node
connection with this property. \n\nccircle{} is also special because it has an
additional argument, for specifying the radius of the circle.
\end{description}
The last two node connections are also special. Rather than connecting the
nodes with an open curve, they enclose the nodes in a box or curved box. You
can think of them as variants of \n\ncline{} and \n\ncarc. In both cases, the
half the width of the box is
\begin{Ex}
\Par{boxsize=dim}
\end{Ex}
You have to set this yourself to the right size, so that the nodes fit inside
the box. The \p{boxsize} parameter actually sets the \p{boxheight} and
\p{boxdepth} parameters. The ends of the boxes extend beyond the nodes by
\p{nodesepA} and \p{nodesepB}.
\begin{description}
\oitem \ncbox{nodeA}{nodeB}
\n\ncbox{} encloses the nodes in a box with straight sides. For example:
\begin{MEx}[0,-.5](4,2.5)
\rput[bl](.5,0){\rnode{A}{Idea 1}}
\rput[tr](3.5,2){\rnode{B}{Idea 2}}
\ncbox[nodesep=.5cm,boxsize=.6,linearc=.2,
linestyle=dashed]{A}{B}
\end{MEx}
\oitem \ncarcbox{nodeA}{nodeB}
\n\ncarcbox{} encloses the nodes in a curved box that is \p{arcangleA} away
from the line connecting the two nodes.
\begin{MEx}[0,-.5](4,2.5)
\rput[bl](.5,0){\rnode{A}{1}}
\rput[tr](3.5,2){\rnode{B}{2}}
\ncarcbox[nodesep=.2cm,boxsize=.4,linearc=.4,
arcangle=50]{<->}{A}{B}
\end{MEx}
The arc is drawn counterclockwise from node A to node B.
\end{description}
There is one other node connection parameter that applies to all the node
connections, except \n\ncarcbox:
\begin{Ex}
\Par{offset=dim}
\end{Ex}
(You can also set \p{offsetA} and \p{offsetB} independently.) This shifts the
point where the connection joins up by <dim> (given the convention that
connections go from left to right).
There are two main uses for this parameter. First, it lets you make two
parallel lines with \n\ncline, as in the following example:
\begin{MEx}[-.5,-.5](3.5,2.5)
\cnodeput(0,0){A}{X}
\cnodeput(3,2){B}{Y}
\psset{nodesep=3pt,offset=4pt,arrows=->}
\ncline{A}{B}
\ncline{B}{A}
\end{MEx}
Second, it lets you join a node connection to a rectangular node at a right
angle, without limiting yourself to positions that lie directly above, below,
or to either side of the center of the node. This is useful, for example, if
you are making several connections to the same node, as in the following
example:
\begin{example**}
\rnode{A}{Word1} and \rnode{B}{Word2} and \rnode{C}{Word3}
\ncbar[offsetB=4pt,angleA=-90,nodesep=3pt]{->}{A}{B}
\ncbar[offsetA=4pt,angleA=-90,nodesep=3pt]{->}{B}{C}
\end{example**}
Sometimes you might be aligning several nodes, such as in a tree, and you want
to ends or the arms of the node connections to line up. This won't happen
naturally if the nodes are of different size, as you can see in this example:
\begin{MEx}[-.5,0](3.5,3)
"\psset{unit=.9}
\Huge
\cnode(1,3){4pt}{a}
\rput[B](0,0){\Rnode{b}{H}}
\rput[B](2,0){\Rnode{c}{a}}
\psset{angleA=90,armA=1,nodesepA=3pt}
\ncdiagg{b}{a}
\ncdiagg{c}{a}
\end{MEx}
%%??? FIXME
If you set the \p{nodesep} or \p{arm} parameter to a negative value, PSTricks
will measure the distance to the beginning of the node connection or to the
end of the arm relative to the center of the node, rather than relative to the
boundary of the node or the beginning of the arm. Here is how we fix the
previous example:
\begin{MEx}[-.5,0](3.5,3)
"\psset{unit=.9}
\Huge
\cnode(1,3){4pt}{a}
\rput[B](0,0){\Rnode{b}{H}}
\rput[B](2,0){\Rnode{c}{a}}
\psset{angleA=90,armA=1,YnodesepA=12pt}
\ncdiagg{b}{a}
\ncdiagg{c}{a}
\end{MEx}
Note also the use of \n\Rnode.
One more parameter trick: By using the \p{border} parameter, you can create
the impression that one node connection passes over another.
The node connection commands make interesting drawing tools as well, as an
alternative to \n\psline{} for connecting two points. There are variants of
the node connection commands for this purpose. Each begins with "pc" (for
``point connection'') rather than "nc". E.g.,
\begin{LVerb}
\pcarc{<->}(3,4)(6,9)
\end{LVerb}
gives the same result as
\begin{LVerb}
\pnode(3,4){A}
\pnode(6,9){B}
\pcarc{<->}{A}{B}
\end{LVerb}
Only \n\nccircle{} does not have a "pc" variant:
\begin{center}
\def\oitem{\GetMacroDef\oitemi}
\def\oitemi#1{\addtoquickref{object}{#1}{\MainFont\Main#1}}
\addtolength{\tabcolsep}{8pt}
\begin{tabular}{ll}
\emph{Command} & \emph{Corresponds to:}\\
\oitem \pcline`{arrows}'\c1\c2
& \n\ncline\\
\oitem \pccurve`{arrows}'\c1\c2
& \n\nccurve\\
\oitem \pcarc`{arrows}'\c1\c2
& \n\ncarc\\
\oitem \pcbar`{arrows}'\c1\c2
& \n\ncbar\\
\oitem \pcdiag`{arrows}'\c1\c2
& \n\ncdiag\\
\oitem \pcdiagg`{arrows}'\c1\c2
& \n\ncdiagg\\
\oitem \pcangle`{arrows}'\c1\c2
& \n\ncangle\\
\oitem \pcangles`{arrows}'\c1\c2
& \n\ncangles\\
\oitem \pcloop`{arrows}'\c1\c2
& \n\ncloop\\
\oitem \pcbox\c1\c2
& \n\ncbox\\
\oitem \pcarcbox\c1\c2
& \n\ncarcbox
\end{tabular}
\end{center}
\Section{Node connections labels: I\label{S-nodelabels}}
Now we come to the commands for attaching labels to the node connections. The
label command must come right after the node connection to which the label is
to be attached. You can attach more than one label to a node connection, and a
label can include more nodes.
The node label commands must end up on the same \TeX{} page as the node
connection to which the label corresponds.
There are two groups of connection labels, which differ in how they select the
point on the node connection. In this section we describe the first group:
\begin{Ex}
\object \ncput`*[par]'{stuff}
\object \naput`*[par]'{stuff}
\object \nbput`*[par]'{stuff}
\end{Ex}
These three command differ in where the labels end up with respect to the line:
\begin{quote}
\begin{tabular}{ll}
\n\ncput & \emph{on} the line\\
\n\naput & \emph{above} the line\\
\n\nbput & \emph{below} the line
\end{tabular}
\end{quote}
(using the convention that node connections go from left to right).
Here is an example:
\begin{MEx}[0,-1.5](3.5,1.5)
\cnode(0,0){.5cm}{root}
\cnode*(3,1.5){4pt}{A}
\cnode*(3,0){4pt}{B}
\cnode*(3,-1.5){4pt}{C}
\psset{nodesep=3pt}
\ncline{root}{A}
\naput{above}
\ncline{root}{B}
\ncput*{on}
\ncline{root}{C}
\nbput{below}
\end{MEx}
\n\naput{} and \n\nbput{} use the same algorithm as \n\uput{} for displacing
the labels, and the distance beteen the line and labels is \p{labelsep} (at
least if the lines are straight).
\n\ncput{} uses the same system as \n\rput{} for setting the reference
point. You change the reference point by setting the
\begin{Ex}
\Par{ref=ref}
\end{Ex}
parameter.
Rotation is also controlled by a graphics parameter:
\begin{Ex}
\Par{nrot=rot}
\end{Ex}
<rot> can be in any of the forms suitable for \n\rput, and you can also use
the form
\begin{LVerb*}
{:<angle>}
\end{LVerb*}
The angle is then measured with respect to the node connection. E.g., if the
angle is "{:U}", then the label runs parallel to the node connection. Since
the label can include other put commands, you really have a lot of control
over the label position.
The next example illustrates the use "{:<angle>}", the \p{offset} parameter,
and \n\pcline:
\begin{MEx}(4,2.3)
\pspolygon(0,0)(4,2)(4,0)
\pcline[offset=12pt]{|-|}(0,0)(4,2)
\ncput*[nrot=:U]{Length}
\end{MEx}
Here is a repeat of an earlier example, now using "{:<angle>}":
\begin{MEx}[0,-1.5](3.5,1.5)
\cnode(0,0){.5cm}{root}
\cnode*(3,1.5){4pt}{A}
\cnode*(3,0){4pt}{B}
\cnode*(3,-1.5){4pt}{C}
\psset{nodesep=3pt,nrot=:U}
\ncline{root}{A}
\naput{above}
\ncline{root}{B}
\ncput*{on}
\ncline{root}{C}
\nbput{below}
\end{MEx}
The position on the node connection is set by the
\begin{Ex}
\Par{npos=num}
\end{Ex}
parameter, roughly according to the following scheme: Each node connection has
potentially one or more segments, including the arms and connecting lines.
A number \p{npos} between 0 and 1 picks a point on the first segment from node
"A" to "B" (fraction \p{npos} from the beginning to the end of the segment),
a number between 1 and 2 picks a number on the second segment, and so on.
Each node connection has its own default value of \p{npos}. If you leave the
\p{npos} parameter value empty (e.g., "[npos=]"), then the default is
substituted. This is the default mode.
Here are the details for each node connection:
\begin{center}
\catcode`\@=11\setbox\@tempboxa=\hbox{1.5}%
\edef\t#1{\noexpand\hbox to \the\wd\@tempboxa{\noexpand\tt\noexpand\hss#1}}
\begin{tabular}{lccc}
\emph{Connection} & \emph{Segments} & \emph{Range} & \emph{Default}\\[2pt]
\n\ncline & 1 & $0\leq pos\leq 1$ & "0.5"\\
\n\nccurve & 1 & $0\leq pos\leq 1$ & "0.5"\\
\n\ncarc & 1 & $0\leq pos\leq 1$ & "0.5"\\
\n\ncbar & 3 & $0\leq pos\leq 3$ & "1.5"\\
\n\ncdiag & 3 & $0\leq pos\leq 3$ & "1.5"\\
\n\ncdiagg & 2 & $0\leq pos\leq 2$ & "0.5"\\
\n\ncangle & 3 & $0\leq pos\leq 3$ & "1.5"\\
\n\ncangles & 4 & $0\leq pos\leq 4$ & "1.5"\\
\n\ncloop & 5 & $0\leq pos\leq 5$ & "2.5"\\
\n\nccircle & 1 & $0\leq pos\leq 1$ & "0.5"\\
\n\ncbox & 4 & $0\leq pos\leq 4$ & "0.5"\\
\n\ncarcbox & 4 & $0\leq pos\leq 4$ & "0.5"
\end{tabular}
\end{center}
Here is an example:
\begin{MEx}(4,3)
\rput[tl](0,3){\rnode{A}{\psframebox{Node A}}}
\rput[br](3.5,0){\ovalnode{B}{Node B}}
\ncangles[angleA=-90,arm=.4cm,linearc=.15]{A}{B}
\ncput*{d}
\nbput[nrot=:D,npos=2.5]{par}
\end{MEx}
With \n\ncbox{} and \n\ncarcbox, the segments run counterclockwise, starting
with the lower side of the box. Hence, with \n\nbput{} the label ends up
outside the box, and with \n\naput{} the label ends up inside the box.
\begin{MEx}[0,-.5](4,2.5)
\rput[bl](.5,0){\rnode{A}{1}}
\rput[tr](3.5,2){\rnode{B}{2}}
\ncarcbox[nodesep=.2cm,boxsize=.4,linearc=.4,
arcangle=50,linestyle=dashed]{<->}{A}{B}
\nbput[nrot=:U]{set}
\nbput[npos=2]{II}
\end{MEx}
If you set the parameter
\begin{Ex}
\Par{shortput=none/nab/tablr/tab}
\end{Ex}
to "nab", then immediately following a node connection or another node
connection label you can use "^" instead of \n\naput{} and "_" instead of
\n\nbput.
\begin{MEx}[0,-1.5](3.5,1.5)
\cnode(0,0){.5cm}{root}
\cnode*(3,1.5){4pt}{A}
\cnode*(3,-1.5){4pt}{C}
\psset{nodesep=3pt,shortput=nab}
\ncline{root}{A}^{$x$}
\ncline{root}{C}_{$y$}
\end{MEx}
You can still have parameter changes with the short "^" and "_" forms. Another
example is given on page \pageref{nab-example}.
If you have set \p{shortput=nab}, and then you want to use a true "^" or "_"
character right after a node connection, you must precede the "^" or "_" by
"{}" so that PSTricks does not convert it to "\naput" or "\nbput".
You can change the characters that you use for the short form with the
\Mac \MakeShortNab{<char1>}{<char2>}
command.\footnote{%
You can also use \n\MakeShortNab{} if you want to use "^" and "_" with
non-standard category codes. Just invoke the command after you have made your
"\catcode" changes.}
The \p{shortput=tablr} and \p{shortput=tab} options are described on pages
\pageref{tablr} and \pageref{tab}, respectively.
\Section{Node connection labels: II}
Now the second group of node connections:
\begin{Ex}
\object \tvput`*[par]'{stuff}
\object \tlput`*[par]'{stuff}
\object \trput`*[par]'{stuff}
\object \thput`*[par]'{stuff}
\object \taput`*[par]'{stuff}
\object \tbput`*[par]'{stuff}
\end{Ex}
The difference between these commands and the "\n*put" commands is that these
find the position as an intermediate point between the centers of the nodes,
either in the horizontal or vertical direction. These are good for trees and
mathematical diagrams, where it can sometimes be nice to have the labels be
horizontally or vertically aligned. The "t" stands for ``tree''.
You specify the position by setting the
\begin{Ex}
\Par{tpos=num}
\end{Ex}
parameter.
\n\tvput, \n\tlput{} and \n\trput{} find the position that lies fraction
<tpos> in the \emph{vertical} direction from the upper node to the lower
node. \n\thput, \n\taput{} and \n\tbput{} find the position that lies fraction
<tpos> in the \emph{horizontal} direction from the left node to the right
node.
Then the commands put the label on or next to the line, as follows:
\begin{center}
\begin{tabular}{lll}
\emph{Command} & \emph{Direction} & \emph{Placement}\\[3pt]
\n\tvput & vertical & middle\\
\n\tlput & vertical & left\\
\n\trput & vertical & right\\
\n\thput & horizontal & middle\\
\n\taput & horizontal & above\\
\n\tbput & horizontal & below
\end{tabular}
\end{center}
Here is an example:
\begin{example*}
\[
\setlength{\arraycolsep}{1.1cm}
\begin{array}{cc}
\Rnode{a}{(X-A)} & \Rnode{b}{A} \\[1.5cm]
\Rnode{c}{x} & \Rnode{d}{\tilde{X}}
\end{array}
\psset{nodesep=5pt,arrows=->}
\everypsbox{\scriptstyle}
\ncline{a}{c}\tlput{r}
\ncline{a}{b}\taput{u}
\ncline[linestyle=dashed]{c}{d}\tbput{b}
\ncline{b}{d}\trput{s}
" \everypsbox{}
" \begin{array}{cc}
" \rnode{a}{(X-A)} & \rnode{b}{a} \\[1.5cm]
" \rnode{c}{x} & \rnode{d}{\tilde{X}}
" \end{array}
" \psset{nodesep=5pt,arrows=->}\everypsbox{\scriptstyle}
" \ncline{a}{c}\nbput{r}
" \ncline{a}{b}\naput{u}
" \ncline[linestyle=dashed]{c}{d}\nbput{b}
" \ncline{b}{d}\naput{s}
\]
\end{example*}
On the left is the diagram with \n\tlput, \n\trput\, \n\tbput{} and \n\Rnode,
as shown in the code. On the right is the same diagram, but with \n\naput\,
\n\nbput{} and \n\rnode.
These do not have a rotation argument or parameter. However, you can rotate
<stuff> in 90 degree increments using box rotations (e.g., \n\rotateleft).
If you set \p{shortput=tablr}, then you can use the following single-character
abbreviations for the "t" put commands:\label{tablr}
\begin{center}
\begin{tabular}{rl}
\emph{Char.} & \emph{Short for:}\\[2pt]
"^" & \n\taput \\
"_" & \n\tbput \\
\DeleteShortMeta "<" & \n\tlput \\
">" & \n\trput
\end{tabular}
\end{center}
You can change the character abbreviations with
\Mac \MakeShortTablr{<char1>}{<char2>}{<char3>}{<char4>}
The "t" put commands, including an example of \p{shortput=tablr}, will be
shown further when we get to mathematical diagrams and trees.
\begin{drivers} The node macros use \n\pstVerb{} and \n\pstverbscale.
\end{drivers}
\Section{Attaching labels to nodes}
The command
\Mac \nput`*[par]'{refangle}{name}{stuff}
affixes <stuff> to node <name>. It is positioned distance \p{labelsep} from
the node, in the direction <refangle> from the center of the node. The
algorithm is the same as for \n\uput. If you want to rotate the node, set the
\begin{Ex}
\Par{rot=rot}
\end{Ex}
parameter, where <rot> is a rotation that would be valid for \n\rput.%
\footnote{Not to be confused with the "nput" parameter.}
The position of the label also takes into account the \p{offsetA}
parameter. If \p{labelsep} is negative, then the distance is from the center
of the node rather than from the boundary, as with \p{nodesep}.
Here is how I used \n\nput{} to mark an angle in a previous example:
\begin{MEx}(4,3)
\rput[br](4,0){\ovalnode{B}{Node B}}
\rput[tl](0,3){\rnode{A}{\psframebox{Node A}}}
\nput[labelsep=0]{-70}{A}{%
\psarcn(0,0){.4cm}{0}{-70}
\uput{.4cm}[-35](0,0){\texttt{angleA}}}
\ncangle[angleA=-70,angleB=90,armB=1cm,linewidth=1.2pt]{A}{B}
\ncput[nrot=:U,npos=1]{\psframe[dimen=middle](0,0)(.35,.35)}
\end{MEx}
\Section{Mathematical diagrams and graphs\label{S-psmatrix}}
For some applications, such as mathematical diagrams and graphs, it is useful
to arrange nodes on a grid. You can do this with alignment environments, such
as \TeX's "\halign"primitive, \LaTeX's "tabular" environment, and \AmS-\TeX's
"\matrix", but PSTricks contains its own alignment environment that is
especially adapted for this purpose:
\begin{Ex}
\object \psmatrix{} ... \string\endpsmatrix
\end{Ex}
Here is an example
\begin{example**}
$
\psmatrix[colsep=1cm,rowsep=1cm]
& A \\
B & E & C \\
& D &
\endpsmatrix
$
\end{example**}
As an alignment environment, \n\psmatrix{} is similar to \AmS-\TeX's
"\matrix". There is no argument for specifying the columns. Instead, you can
just use as many columns as you need. The entries are horizontally centered.
Rows are ended by "\\". \n\psmatrix{} can be used in or out of math mode.
Our first example wasn't very interesting, because we didn't make use of the
nodes. Actually, each entry is a node. The name of the node in row <row> and
column <col> is "{<row>,<col>}", with no spaces. Let's see some node
connections:
\begin{example**}
$
\psmatrix[colsep=1cm]
& X \\
Y & Z
\endpsmatrix
\everypsbox{\scriptstyle}%
\psset{nodesep=3pt,arrows=->}
\ncline{1,2}{2,1}
\tlput{f}
\ncline{1,2}{2,2}
\trput{g}
\ncline[linestyle=dotted]{2,1}{2,2}
\tbput{h}
$
\end{example**}
You can include the node connections inside the \n\psmatrix, in the last entry
and right before \n\endpsmatrix. One advantage to doing this is that
\p{shortput=tab} is the default within a \n\psmatrix.
\begin{example**}
$
\begin{psmatrix}
U \\
& X\times_Z Y & X \\
& Y & Z
\psset{arrows=->,nodesep=3pt}
\everypsbox{\scriptstyle}
\ncline{1,1}{2,2}_{y}
\ncline[doubleline=true,linestyle=dashed]{-}{1,1}{2,3}^{x}
\ncline{2,2}{3,2}<{q}
\ncline{2,2}{2,3}_{p}
\ncline{2,3}{3,3}>{f}
\ncline{3,2}{3,3}_{g}
\end{psmatrix}
$
\end{example**}
You can change the kind of nodes that are made by setting the
\begin{Ex}
\Par{mnode=type}
\end{Ex}
parameter. Valid types are "R", "r", "C", "f", "p", "circle", "oval", "dia",
"tri", "dot" and "none", standing for \n\Rnode, \n\rnode, \n\Cnode, \n\fnode,
\n\pnode, \n\circlenode, \n\ovalnode, \n\dotnode{} and no node,
respectively. Note that for circles, you use \p{mnode=C} and set the radius
with the \p{radius} parameter.
For example:\label{nab-example}
\begin{example**}
\psmatrix[mnode=circle,colsep=1]
& A \\
B & E & C \\
& D &
\endpsmatrix
\psset{shortput=nab,arrows=->,labelsep=3pt}
\small
\ncline{2,2}{2,3}^[npos=.75]{a}
\ncline{2,2}{2,1}^{b}
\ncline{3,2}{2,1}^{c}
\ncarc[arcangle=-40,border=3pt]{3,2}{1,2}
_[npos=.3]{d}^[npos=.7]{e}
\ncarc[arcangle=12]{1,2}{2,1}^{f}
\ncarc[arcangle=12]{2,1}{1,2}^{g}
\end{example**}
Note that a node is made only for the non-empty entries. You can also specify
a node for the empty entries by setting the
\begin{Ex}
\Par{emnode=type}
\end{Ex}
parameter.
You can change parameters for a single entry by starting this entry with the
parameter changes, enclosed in square brackets. Note that the changes affect
the way the node is made, but not contents of the entry (use \n\psset{} for
this purpose). For example:
\begin{example**}
$
\psmatrix[colsep=1cm]
& [mnode=circle] X \\
Y & Z
\endpsmatrix
\psset{nodesep=3pt,arrows=->}
\ncline{1,2}{2,1}
\ncline{1,2}{2,2}
\ncline[linestyle=dotted]{2,1}{2,2}
$
\end{example**}
If you want your entry to begin with a "[" that is not meant to indicate
parameter changes, the precede it by "{}".
You can assign your own name to a node by setting the
\begin{Ex}
\Par{name=<name>}
\end{Ex}
parameter at the beginning of the entry, as described above. You can still
refer to the node by "{<row>,<col>}", but here are a few reasons for giving
your own name to a node:
\begin{itemize}
\item The name may be easier to keep track of;
\item Unlike the "{<row>,<col>}" names, the names you give remain valid
even when you add extra rows or columns to your matrix.
\item The names remain valid even when you start a new \n\psmatrix{} that
reuses the "{<row>,<col>}" names.
\end{itemize}
Here a few more things you should know:
\begin{itemize}
\item The baselines of the nodes pass through the centers of the
nodes. \n\psmatrix{} achieves this by setting the
\begin{Ex}
\Par{nodealign=true/false}
\end{Ex}
parameter to "true". You can also set this parameter outside of \n\psmatrix{}
when you want this kind of alignment.
\item You can left or right-justify the nodes by setting the
\begin{Ex}
\Par{mcol=l/r/c}
\end{Ex}
parameter. "l", "r" and "c" stand for "left", "right" and "center",
respectively.
\item The space between rows and columns is set by the
\begin{Ex}
\Par{rowsep=dim}
\Par{colsep=dim}
\end{Ex}
parameters.
\item If you want all the nodes to have a fixed width, set
\begin{Ex}
\Par{mnodesize=dim}
\end{Ex}
to a positive value.
\item If \n\psmatrix{} is used in math mode, all the entries are set in math
mode, but you can switch a single entry out of math mode by starting and
ending the entry with "$".
\item The radius of the "c" \p{mnode} (corresponding to \n\cnode) is set by
the \p{radius} parameter.
\item Like in \LaTeX, you can end a row with "\\[<dim>]" to insert an extra
space <dim> between rows.
\item The command "\psrowhookii" is executed, if defined, at the beginning of
every entry in row "ii" (row 2), and the command "\pscolhookv" is executed at
athe beginning of every entry in column "v" (etc.). You can use these hooks,
for example, to change the spacing between two columns, or to use a special
\p{mnode} for all the entries in a particular row.
\item An entry can itself be a node. You might do this if you want an entry
to have two shapes.
\item If you want an entry to stretch across several (<int>) columns, use the
\Mac \psspan{int}
\emph{at the end of the entry}. This is like Plain \TeX's \n\multispan, or
\LaTeX's \n\multicolumn, but the template for the current column (the first
column that is spanned) is still used. If you want wipe out the template as
well, use "\multispan{<int>}" \emph{at the beginning of the entry} instead.
If you just want to wipe out the template, use "\omit" before the entry.
\item \n\psmatrix{} can be nested, but then all node connections and other
references to the nodes in the "{<row>,<col>}" form for the nested matrix
\emph{must go inside} the \n\psmatrix. This is how PSTricks decides which
matrix you are referring to. It is still neatest to put all the node
connections towards the end; just be sure to put them before \n\endpsmatrix.
Be careful also not to refer to a node until it actually appears. The whole
matrix can itself go inside a node, and node connections can be made as
usual. This is not the same as connecting nodes from two different
\n\psmatrix's. To do this, you must give the nodes names and refer to them
by these names.
\end{itemize}
\section{Obsolete put commands}
This is old documentation, but these commands will continue to be supported.
There is also an obsolete command \n\Lput\MainIndex\Lput{} for putting labels
next to node connections. The syntax is
\begin{LVerb*}
\Lput{<labelsep>}[<refpoint>]{<rotation>}(<pos>){<stuff>}
\end{LVerb*}
It is a combination of \n\Rput{} and \n\lput, equivalent to
\begin{LVerb*}
\lput(<pos>){\Rput{<labelsep>}[<refpoint>]{<rotation>}(0,0){<stuff>}}
\end{LVerb*}
\n\Mput\MainIndex\Mput{} is a short version of \n\Lput{} with no
"{<rotation>}" or "(<pos>)" argument. \n\Lput{} and \n\Mput{} remain part of
PSTricks only for backwards compatibility.
Here are the node label commands:
\begin{description}
\mitem \lput`*[refpoint]{rotation}'(pos){stuff}
The "l" stands for ``label''. Here is an example illustrating the use of the
optional star and ":<angle>" with \n\lput, as well as the use of the
\p{offset} parameter with \n\pcline:
\begin{MEx}(4,2.3)
\pspolygon(0,0)(4,2)(4,0)
\pcline[offset=12pt]{|-|}(0,0)(4,2)
\lput*{:U}{Length}
\end{MEx}
(Remember that with the "put" commands, you can omit the coordinate if you
include the angle of rotation. You are likely to use this feature with the
node label commands.)
With \n\lput{} and \n\rput, you have a lot of control over the position of the
label. E.g.,
\begin{MEx}(4,2)
\pcline(0,0)(4,2)
\lput{:U}{\rput[r]{N}(0,.4){label}}
\end{MEx}
puts the label upright on the page, with right side located .4 centimeters
``above'' the position ".5" of the node connection (above if the node
connection points to the right). However, the \n\aput{} and \n\bput{} commands
described below handle the most common cases without \n\rput.\footnote{%
There is also an obsolete command \n\Lput\MainIndex\Lput{} for putting labels
next to node connections. The syntax is
\begin{LVerb*}
\Lput{<labelsep>}[<refpoint>]{<rotation>}(<pos>){<stuff>}
\end{LVerb*}
It is a combination of \n\Rput{} and \n\lput, equivalent to
\begin{LVerb*}
\lput(<pos>){\Rput{<labelsep>}[<refpoint>]{<rotation>}(0,0){<stuff>}}
\end{LVerb*}
\n\Mput\MainIndex\Mput{} is a short version of \n\Lput{} with no
"{<rotation>}" or "(<pos>)" argument. \n\Lput{} and \n\Mput{} remain part of
PSTricks only for backwards compatibility.}
\mitem \aput`*[labelsep]{angle}'(pos){stuff}
<stuff> is positioned distance \n\pslabelsep{} \emph{above} the node
connection, given the convention that node connections point to the right.
"\aput" is a node-connection variant of \n\uput. For example:
\begin{MEx}(4,2)
\pspolygon(0,0)(4,2)(4,0)
\pcline[linestyle=none](0,0)(4,2)
\aput{:U}{Hypotenuse}
\end{MEx}
\mitem \bput`*[labelsep]{angle}'(pos){stuff}
This is like \n\aput, but <stuff> is positioned \emph{below} the node
connection.
\end{description}
It is fairly common to want to use the default position and rotation with
these node connections, but you have to include at least one of these
arguments. Therefore, PSTricks contains some variants:
\begin{Ex}
\object \mput`*[refpoint]'{stuff}
\object \Aput`*[labelsep]'{stuff}
\object \Bput`*[labelsep]'{stuff}
\end{Ex}
of \n\lput, \n\aput{} and \n\bput, respectively, that have no angle or
positioning argument. For example:
\begin{MEx}(4,2)
\cnode*(0,0){3pt}{A}
\cnode*(4,2){3pt}{B}
\ncline[nodesep=3pt]{A}{B}
\mput*{1}
\end{MEx}
Here is another:
\begin{MEx}(4,2)
\pcline{<->}(0,0)(4,2)
\Aput{Label}
\end{MEx}
\endinput
%% END psd-node.tex
|