summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/xypic/xyweb.doc
blob: 06b77d7e31085f93b0c1833a95cb3f630ccca73f (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
%% $Id: xyweb.doc,v 3.3 1996/12/18 09:52:11 ross Exp $
%%
%% Xy-pic ``Lattice and web'' feature.
%% Copyright (c) 1994-1996	Ross Moore	<ross@mpce.mq.edu.au>
%%
%% This file is part of the Xy-pic package for graphs and diagrams in TeX.
%% See the companion README and INSTALL files for further information.
%% Copyright (c) 1991-1996	Kristoffer H. Rose	<krisrose@brics.dk>
%%
%% The Xy-pic package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by the
%% Free Software Foundation; either version 2 of the License, or (at your
%% option) any later version.
%%
%% The Xy-pic package is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%% or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
%% for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this package; if not, write to the Free Software Foundation, Inc.,
%% 675 Mass Ave, Cambridge, MA 02139, USA.
%%
\ifx\xyloaded\undefined \input xy \fi

\xyprovide{web}{Lattice and web feature}{\stripRCS$Revision: 3.3 $}%
 {Ross Moore}{ross@mpce.mq.edu.au}%
 {Mathematics Department, Macquarie University, NSW~2109, Australia}

\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\noindent
 This feature provides macros to facilitate typesetting of arrangements
 of points within a 2-dimensional lattice or ``web-like'' structure.

\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph*{Header:}\leavevmode
\DOCHEADER
\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DOCMODE(
\message{lattices,}
\DOCMODE)

\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

We need two counters and macros to access their values.

\DOCMODE(
\xynew@{count}\lattice@A
\xynew@{count}\lattice@B
\xydef@\latticeA{\lattice@A}
\xydef@\latticeB{\lattice@B}
\DOCMODE)

\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\subsection{Lattices}
%\noindent
Currently the only routines implemented with this feature are some ``quick
and dirty'' macros for dropping objects at the points of an integer lattice.
\TODO: More sophisticated routines will be developed for later versions of
\Xy-pic, as the need arises.

Mathematically speaking, let $\vec u$ and $\vec v$ be vectors pointing in
independent directions within the plane. Then the lattice spanned by
$\vec u$ and $\vec v$ is the infinite set of points $L$ given by:
$$
L\;=\; \bigl\{ a\,\vec u + b\,\vec v\;;\; 
\mbox{ for $a$, $b$ integers} \bigr\}\,.
$$
Within \Xy-pic the vectors $\vec u$ and $\vec v$ can be established
as the current coordinate basis vectors.
The following macros typeset a finite subset of an abstract lattice. 
%
\begin{defs}
|\xylattice#1#2#3#4|  	&  points in lattice\cr
|\croplattice#1#2#3#4#5#6#7#8|\kern-44pt&\cr
			&\dots in specific rectangle.\cr
\end{defs}
%
\noindent
The parameters |#1| \dots |#4| are to be integers
$a_{\min}$, $a_{\max}$, $b_{\min}$ and $b_{\max}$, 
so that the portion of the lattice to be typeset 
is that collection of vectors in $L$ for which
$a_{\min} \le a \le a_{\max}$ and $b_{\min} \le b \le b_{\max}$.
%
\begin{code}
\def\latticebody{%
\ifnum\latticeA=1 \ifnum\latticeB=-1 %
\else\drop{\circ}\fi\else\drop{\circ}\fi}
\xy *\xybox{0;<1.5pc,1mm>:<1mm,1.5pc>::
,0,{\xylattice{-4}4{-3}3}
 ,(1,-1)="a"*{\bullet}*+<2pt>!UL{a}
 ,(-1,1)."a"*\frm{.}}="L"
,{"L"+L \ar "L"+R*+!L{s^{(1)}}}
,{"L"+D \ar "L"+U*+!D{s^{(2)}}}
\endxy
\end{code}
$$\docode$$
\displaycode

In the above code, notice how the basis is first established then the 
|\xylattice| typeset. Doing this within an |\xybox| allows axes 
to be sized and placed appropriately.
Since lattice points are determined by their (integer) coordinate 
displacements, they can be revisited to add extra <object>s into 
the overall picture. More generally, the origin for lattice-coordinates 
is the current <pos> $c$, when the |\xylattice| command is encountered. 
Easy accessibility is maintained, as seen in the next example. 

\medskip

When the basis vectors $\vec u$ and $\vec v$ are not perpendicular
the collection of points with $a,b$ in these ranges will fill out 
a skew parallelogram. Generally it is useful to plot only those points 
lying within a fixed rectangle.
This is the purpose of |\croplattice|, with its extra parameters 
|#5| \dots |#8| determining the `cropping' rectangle within which
lattice points will be typeset. Other points will not be typeset
even when $a$ and $b$ are within the specified ranges.
Explicitly the horizontal range of the cropping rectangle is $X_{\min}$ 
to $X_{\max}$, with $X_{\min}$ being the $X$-coordinate of the vector 
$|#5|\times\vec u$, where |#5| is a <number> (not necessarily an integer). 
Similarly  $X_{\max}$ is the $X$-coordinate of $|#6|\times\vec u$.
The vertical extents are $Y_{\min}$ and $Y_{\max}$, given by the
$Y$-coordinates of $|#7|\times\vec v$ and $|#8|\times\vec v$ respectively.
%
\begin{code}
\def\latticebody{%
\ifnum\latticeA=1 \ifnum\latticeB=-1 %
\else \drop{\circ}\fi\else
\ifnum\latticeA=0 \ifnum\latticeB=1\else
\drop{\circ}\fi\else\drop{\circ}\fi\fi}
\xy +(2,2)="o",0*\xybox{%
 0;<3pc,1.5mm>:<0.72pc,1.65pc>::,{"o"
 \croplattice{-4}4{-4}4{-2.6}{2.6}{-3}3}
 ,"o"+(0,1)="a"*{\bullet}*+!D{\alpha}
 ,"o"+(1,-1)="b"*{\bullet}*+!L{\beta}
 ,"o"+(0,-1)="c","o"+(-1,1)="d"
 ,"a"."c"="e",!DR*{};"a"**\dir{.}
 ,"e",!UL*{};"c"**\dir{.}
 ,"b"."d"="f",!DL*{};"b"**\dir{.}
 ,"f",!UR*{};"d"**\dir{.}
 ,"e"."f"*\frm{.}}="L","o"."L"="L"
 ,{"L"+L \ar "L"+R*+!L{s^{(1)}}}
 ,{"L"+D \ar "L"+U*+!D{s^{(2)}}}
\endxy
\end{code}
$$\docode$$
\displaycode

\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The routines |\xylattice| and |\croplattice| simply cycle through the 
allowable range of values for |\lattice@A| and |\lattice@B|, 
with |\lattice@B| varying within the inner loop.

\DOCMODE(
\xydef@\xylattice#1#2#3#4{\xy@{LATTICE}{\xylattice@{#1}{#2}{#3}{#4}}}%

\xydef@\xylattice@#1#2#3#4{%
 \lattice@A=#1\relax
 \loop \bgroup\lattice@B=#3\relax
  \innerlatticeloop@{#4}%
  \edef\tmp@{\egroup
   \X@min=\the\X@min \X@max=\the\X@max
   \Y@min=\the\Y@min \Y@max=\the\Y@max 
  }\tmp@ \ifnum\lattice@A<#2\relax \advance\lattice@A\@ne
 \repeat }

\xydef@\innerlatticeloop@#1{%
 \loop \enter@{\cfromthec@}\enter@{\cplusthec@}%
  \vfromcartesian@@ \the\lattice@A,\the\lattice@B @%
  \edef\latticeX{\expandafter\removePT@\the\X@c}%
  \edef\latticeY{\expandafter\removePT@\the\Y@c}%
  \leave@ \latticebody \leave@
 \ifnum\lattice@B<#1\relax \advance\lattice@B\@ne
 \repeat }
\DOCMODE)

With |\xylattice| getting the picture size correct is simply
a matter of passing |\X@min|, |X@max|, etc. outside of the inner group.
However with |\croplattice| these are first set to correspond to the
`cropping rectangle' then subsequently merged with their original
values.

\DOCMODE(
\xydef@\croplattice#1#2#3#4#5#6#7#8{\xy@{LATTICE}%
 {\xycroplattice@{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}}%

\xydef@\xycroplattice@#1#2#3#4#5#6#7#8{%
 \enter@{\X@min=\the\X@min \X@max=\the\X@max 
  \Y@min=\the\Y@min \Y@max=\the\Y@max}%
 \enter@{\cfromthec@}\enter@{\cplusthec@}%
  \vfromcartesian@@ #5,0 @\leave@ \X@min=\X@c \leave@
 \enter@{\cfromthec@}\enter@{\cplusthec@}%
  \vfromcartesian@@ #6,0 @\leave@ \X@max=\X@c \leave@
 \enter@{\cfromthec@}\enter@{\cplusthec@}%
  \vfromcartesian@@ 0,#7 @\leave@ \Y@min=\Y@c \leave@
 \enter@{\cfromthec@}\enter@{\cplusthec@}%
  \vfromcartesian@@ 0,#8 @\leave@ \Y@max=\Y@c \leave@
 \lattice@A=#1\relax
 \loop
  \bgroup\lattice@B=#3\relax
   \enter@{\cfromthec@}\innercroplatticeloop@{#4}\leave@
  \egroup
  \ifnum\lattice@A<#2\relax \advance\lattice@A\@ne
 \repeat \mergecropextents@ }

\xydef@\innercroplatticeloop@#1{%
 \loop 
  \enter@{\cfromthec@}\enter@{\cplusthec@}%
   \vfromcartesian@@ \the\lattice@A,\the\lattice@B @%
   \edef\latticeX{\expandafter\removePT@\the\X@c}%
   \edef\latticeY{\expandafter\removePT@\the\Y@c}%
  \leave@ \DN@{\latticebody}%
  \ifdim\X@c<\X@min\DN@{}%
  \else\ifdim\X@c>\X@max\DN@{}%
  \else\ifdim\Y@c<\Y@min\DN@{}%
  \else\ifdim\Y@c>\Y@max\DN@{}%
  \fi\fi\fi\fi \next@ \leave@
 \ifnum\lattice@B<#1\relax \advance\lattice@B\@ne
 \repeat }

\xydef@\mergecropextents@{%
 \edef\tmp@{%
  \noexpand\ifdim\X@min>\the\X@min \X@min=\the\X@min\noexpand\fi
  \noexpand\ifdim\X@max<\the\X@max \X@max=\the\X@max\noexpand\fi
  \noexpand\ifdim\Y@min>\the\Y@min \Y@min=\the\Y@min\noexpand\fi
  \noexpand\ifdim\Y@max<\the\Y@max \Y@max=\the\Y@max\noexpand\fi}%
 \leave@ \tmp@ }
\DOCMODE)

\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\paragraph*{The |\latticebody| macro.}
At each lattice point within the specified range for $a,b$ (and within
the cropping rectangle when |\croplattice| is used), a macro called
|\latticebody| is expanded. This is meant to be user-definable,
so as to be able to adapt to any specific requirement.
It has a default expansion given by \dots
$$
|\def\latticebody{\drop{\bullet}}|\,.
$$
The following macros may be useful when specifying what to do at each
point of the lattice. 
%
\begin{defs}
|\latticebody|  &  expanded at lattice points \cr
|\defaultlatticebody|\kern-20pt & \kern20pt resets to default \cr
|\latticeA|  & $a$-value of lattice point\cr
|\latticeB|  & $b$-value of lattice point\cr
|\latticeX|  & $X$-coord, offset in |pt|s\dots\cr
|\latticeY|  & $Y$-coord, \dots from lattice origin.\cr
\end{defs}
As in the examples presented above, the object dropped at the lattice
point can be varied according to its location, or omitted altogether.

\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The default |\latticebody| macro \dots

\DOCMODE(
\xydef@\deflatticebody@{\def\latticebody{\drop{\bullet}}}
\xydef@\defaultlatticebody{\deflatticebody@}
\deflatticebody@
\DOCMODE)

\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In the final example the |\latticebody| macro
performs a calculation to decide which lattice points
should be emphasised:
%
\begin{code}
\def\latticebody{\dimen0=\latticeX pt
 \ifdim\dimen0>0pt \divide\dimen0 by 64
 \dimen0=\latticeY\dimen0 \relax
 \ifdim 0pt>\dimen0 \dimen0=-\dimen0 \fi
 \ifdim 10pt>\dimen0 \drop{\bullet}%
 \else\drop{.}\fi \else\drop{.}\fi}
\xy*\xybox{0;<3pc,2.57mm>:<.83pc,2.25pc>::
,0,{\croplattice{-3}5{-5}5
  {-1.3}{4.5}{-3.4}{4.4}}}="L"
,{"L"+L \ar "L"+!R*+!L{\sigma^{(1)}}}
,{"L"+D \ar "L"+!U*+!D{\sigma^{(2)}}}
\endxy
\end{code}
%\displaycode
$$\docode$$
\displaycode

\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\paragraph*{The end \& Log}\leavevmode

DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DOCMODE(
\xyendinput

% $Log: xyweb.doc,v $
% Revision 3.3  1996/12/18  09:52:11  ross
% no changes
%
% Revision 3.1  1995/09/05 20:36:33  ross
% Release!
%
% Revision 3.0  1995/07/07  20:13:19  ross
% Major release w/new User's Guide!
%
% Revision 2.13  1995/07/05  10:36:22  ross
% Ready for v3 release?
%
% NEW for version 3.
\DOCMODE)

\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Tell Emacs that this is a LaTeX document and how it is formatted:
% Local Variables:
% mode:latex
% fill-column:77
% End: