%% $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 %% %% 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 %% %% 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 s into the overall picture. More generally, the origin for lattice-coordinates is the current $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 (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: