% This is diagram.sty, intended for drawing commuting diagrams as PS \specials
% in LaTeX. Original author Sean Bechhofer.
% Improved, modified to use Rokiki's dvips 5.4.7 and generally crapped around with
% by David Murphy.
% This is version 1.0\beta

% diagram.sty and associated files is copyright (c) 1991 David Murphy and Sean
% Bechhofer. Please note the following conditions:
%
% 1. You can compile, use, copy and distribute this software without fee
% provided that this copyright notice and permissions are preserved.
%
% 2. You can modify this software provided (a) you make no deletions; (b)
% you mark all changes clearly (including the version number message); and
% (c) if you distribute it, you change the name.
%
% 3. This software is provided for free, on an "as-is" basis, without
% express or implied warranty.

% The intention of (2) is to prevent a proliferation of incompatable
% versions with the same name.  Commenting out code does not count as a
% deletion.  If you have improvements or bug fixes, please forward them to
% me rather than distributing a new version.
\message{This is not Paul Taylor's commuting diagrams package;}
\message{please do not acknowledge him. Version 1.0, 1991.}

% This file depends on pspicture.ps and pspicture-dvips.sty.
% The latter follows in this version.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                pspicture.sty Version 2.0
%
%                Originally by D. P. Carlisle (carlisle@uk.ac.man.cs)
%                Computer Science Department, Manchester University
%                Heavily modified by David Murphy (david@gmdzi.gmd.de)
%
% A style file to redefine picture mode commands to use
% postscript \special's rather than the circle and line fonts.
% The \put and \multiput commands are not changed, ie
% picture objects are positioned by TeX not by PS moveto.
% The \framebox \makebox and \shortstack commands are unchanged.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%\circle and  \circle*.
%       Use as in LaTeX book but with no maximum diameter.
%   The thickness of the circle is altered by the \linethickness command.
%
%\oval.
%       Use as in LaTeX book, but as there is no maximum diameter for
%   the circular arcs, the oval (in the absence of the optional [tr] etc)
%   always consists of two semi-circular arcs joined by a pair of parallel
%   lines. To obtain a `rectangle with rounded corners' the oval command
%   has a second optional argument (given first pspicmac).
%   \oval[20](100,200)[t]
%   Produces the top half of an oval with quarter circles of radius
%   20*unitlength.
%   If unitlength = 1pt then this is equivalent to the standard oval command.
%   In general \oval[R](x,y) uses circular arcs of radius max(R,min(x/2,y/2)).
%
%\line and \vector.
%   Use as in LaTeX book but with no restriction on the available slopes.
%   The thickness of a sloping line is altered by the \linethickness command.
%
%\Line and \Vector.
%   New forms of the line and vector commands.
%   \put(x1,y1){\Line(x2,y2)}
%   produces a line from (x1,y1) to (x1+x2,y1+y2) and similarly for \Vector.
%
%\Curve
%   Like \Line except that it produce a curve pspicmac
%   \put(x1,y1){\Curve(x2,y2){m}}
%   produces a curve from (x1,y1) to (x1+x2,y1+y2). the amount of curvature
%   is controlled by m but try 1 or -1 first. m does not have to be an integer.
%   negative numbers curve the opposite way to positive numbers.
%
%\thinlines, \thicklines and \linethickness.
%       These commands alter the thickness of ALL lines including
%   slanted lines and circular arcs.
%
%\arrowlength.
%   A new command which specifies the size of the arrowhead drawn by the
%   \vector and \Vector commands. Like \linethickness it does not get
%   multiplied by \unitlength. At present the arrowhead is triangular.
%   If a head with curved sides more like the standard LaTeX head is required
%   the definition of pspicmacA in pspicture.ps should be altered.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% if for dashes
\newif\ifdashed \dashedfalse

% strip the final `pt' off string returned by \the
{\catcode`t=12\catcode`p=12\gdef\noPT#1pt{#1}}
\def\strippt#1{\expandafter\noPT\the#1\space}

\def\@circle#1{%
  \@tempdimb #1\unitlength
  \special{"
       \strippt\@wholewidth
       \strippt\@tempdimb
       pspicmacC}}

\def\@dot#1{%
  \@tempdimb #1\unitlength
  \special{"
       \strippt\@tempdimb
       pspicmacD}}

\def\line(#1,#2)#3{\ifdashed
  \@linelen=#3\unitlength
  \special{"
       \strippt\@wholewidth
       #1
       #2
       \strippt\@linelen
       pspicmacdL}\else
  \@linelen=#3\unitlength
  \special{"
       \strippt\@wholewidth
       #1
       #2
       \strippt\@linelen
       pspicmacL}\fi}

\def\vector(#1,#2)#3{\ifdashed
  \@linelen=#3\unitlength
  \special{"
       \strippt\@arrowlength
       \strippt\@wholewidth
       #1
       #2
       \strippt\@linelen
       pspicmacdV}\else
  \@linelen=#3\unitlength
  \special{"
       \strippt\@arrowlength
       \strippt\@wholewidth
       #1
       #2
       \strippt\@linelen
       pspicmacV}\fi}

\def\@FlArrow(#1,#2)(#3,#4)(#5,#6)(#7,#8){%
  \@headlen=0.06\unitlength
  \@headwid=0.03\unitlength
  \@xa=#1\unitlength  \@ya=#2\unitlength
  \@xb=#3\unitlength  \@yb=#4\unitlength
  \@dxa=#5\unitlength \@dya=#6\unitlength
  \@dxb=#7\unitlength \@dyb=#8\unitlength
  \special{"
       \strippt\@dxa
       \strippt\@dya
       \strippt\@dxb
       \strippt\@dyb
       \strippt\@xa
       \strippt\@ya
       \strippt\@xb
       \strippt\@yb
       \strippt\@wholewidth
       \strippt\@headwid
       \strippt\@headlen
       arrowfl}}

\def\oval{\@ifnextchar[{\@ov@l}%
           {\count@=\maxdimen \divide\count@ by \unitlength \@ov@l[\count@]}}%
\def\@ov@l[#1](#2,#3){\@ifnextchar[{\@oval[#1](#2,#3)}{\@oval[#1](#2,#3)[]}}%
\def\@oval[#1](#2,#3)[#4]{\begingroup
  \@tempdimb #1\unitlength
  \@ovxx #2\unitlength
  \@ovyy #3\unitlength
  \def\r{\def\TL{0 }\def\BL{0 }}%
  \def\l{\def\TR{0 }\def\BR{0 }}%
  \def\t{\def\BL{0 }\def\BR{0 }}%
  \def\b{\def\TL{0 }\def\TR{0 }}%
  \def\TL{1 }\def\BL{1 }\def\TR{1 }\def\BR{1 }%
  \@tfor\@tempa :=#4\do{\csname\@tempa\endcsname}%
  \special{"
       \BR\BL\TR\TL
       \strippt\@wholewidth
       \strippt\@tempdimb
       \strippt\@ovxx
       \strippt\@ovyy
       pspicmacO}%
  \endgroup}

\def\Line(#1,#2){%
  \@ovxx #1\unitlength
  \@ovyy #2\unitlength
  \special{"
       \strippt\@wholewidth
       \strippt\@ovxx
       \strippt\@ovyy
       pspicmacL2}}

\def\Curve(#1,#2)#3{\ifdashed
  \@ovxx #1\unitlength
  \@ovyy #2\unitlength
  \special{"
       \strippt\@wholewidth
       \strippt\@ovxx
       \strippt\@ovyy
       #3
       pspicmacdC2}\else
  \@ovxx #1\unitlength
  \@ovyy #2\unitlength
  \special{"
       \strippt\@wholewidth
       \strippt\@ovxx
       \strippt\@ovyy
       #3
       pspicmacC2}\fi}

\def\Vector(#1,#2){%
  \@ovxx #1\unitlength
  \@ovyy #2\unitlength
  \special{"
       \strippt\@arrowlength
       \strippt\@wholewidth
       \strippt\@ovxx
       \strippt\@ovyy
       pspicmacV2}}

\newdimen\@arrowlength
\def\arrowlength#1{\@arrowlength #1}
\arrowlength{4pt}

% A few dimensions that count...
\newdimen\@headwid \newdimen\@headlen
\newdimen\@xa \newdimen\@ya \newdimen\@xb \newdimen\@yb
\newdimen\@dxa \newdimen\@dya \newdimen\@dxb \newdimen\@dyb
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%% Top level environments.
% First, set-up a length to keep the external value of \unitlength in it.
\newlength{\externalunitlength}
\newdimen\diagramcellsize
\diagramcellsize=8em

% Now deal with diagrams with numbering.
\newcounter{diagram}
\def\thediagram{\arabic{diagram}}
\newsavebox{\diagramlabel}

% Now the unnumbered version
\newenvironment{diagram*}{\refstepcounter{diagram}%
 \savebox{\diagramlabel}[0pt]{}\@diagram}{\end@diagram}
\newenvironment{diagram}{\refstepcounter{diagram}%
 \savebox{\diagramlabel}{\hbox{\rm (\thediagram)}}\@diagram}{\end@diagram}

\def\@diagram{\[
 \unitlength\diagramcellsize%
 \vcenter\bgroup\hbox to \displaywidth\bgroup\hfil\picture}
\def\end@diagram{\endpicture\hfil\egroup\egroup\llap{\usebox{\diagramlabel}}\]}

%%%%%%%%% Directions
\def\north{0}
\def\neast{1}
\def\east{2}
\def\seast{3}
\def\south{4}
\def\swest{5}
\def\west{6}
\def\nwest{7}
\def\nneast{8}
\def\eneast{9}
\def\eseast{10}
\def\sseast{11}
\def\sswest{12}
\def\wswest{13}
\def\wnwest{14}
\def\nnwest{15}
\def\po{0}
\def\st{1}

\def\clock{0}
\def\anti{1}

\def\near{0}
\def\far{1}

%%%%%%%%% Positioning
% Command to position an object; puts #3 in math mode at coords. (#1,#2).
\def\object(#1,#2)#3{\put(#1,#2){\makebox(0,0){$#3$}}}

% !!! This use of absolute coordinates is dreadful. We should work in
% multiples of \unitlength (DVJM).
\def\leftobject(#1,#2)#3{\put(#1,#2){\makebox(0,0)
                                        {\makebox(0.3,0)[r]{$#3$}}}}
\def\rightobject(#1,#2)#3{\put(#1,#2){\makebox(0,0)
                                        {\makebox(0.3,0)[l]{$#3$}}}}

%%%%%%%%% Short Arrows
% Drawing short arrow bodies for tailed arrows;
\def\arrshbdne{\put ( 0.15, 0.15){\line( 1, 1){0.75}}}
\def\arrshbdnw{\put (-0.15, 0.15){\line(-1, 1){0.75}}}
\def\arrshbdse{\put ( 0.15,-0.15){\line( 1,-1){0.75}}}
\def\arrshbdsw{\put (-0.15,-0.15){\line(-1,-1){0.75}}}
\def\arrshbdn{\put  ( 0,    0.15){\line( 0, 1){0.75}}}
\def\arrshbde{\put  ( 0.25, 0   ){\line( 1, 0){0.55}}}
\def\arrshbds{\put  ( 0,   -0.15){\line( 0,-1){0.75}}}
\def\arrshbdw{\put  (-0.25, 0   ){\line(-1, 0){0.55}}}

% Drawing normal sized arrow bodies;
\def\arrbdne{\put ( 0.1, 0.1){\line( 1, 1){0.8}}}
\def\arrbdse{\put ( 0.1,-0.1){\line( 1,-1){0.8}}}
\def\arrbdnw{\put (-0.1, 0.1){\line(-1, 1){0.8}}}
\def\arrbdsw{\put (-0.1,-0.1){\line(-1,-1){0.8}}}
\def\arrbdn{\put  ( 0,   0.1){\line( 0, 1){0.8}}}
\def\arrbde{\put  ( 0.2, 0  ){\line( 1, 0){0.6}}}
\def\arrbds{\put  ( 0,  -0.1){\line( 0,-1){0.8}}}
\def\arrbdw{\put  (-0.2, 0  ){\line(-1, 0){0.6}}}

% !!! This bit's a special that might need further touching up (SB)
\def\arrbdnne{\put ( 0.05, 0.1  ){\line( 1, 2){0.4}}}
\def\arrbdene{\put ( 0.15, 0.075){\line( 2, 1){0.7}}}
\def\arrbdese{\put ( 0.15,-0.075){\line( 2,-1){0.7}}}
\def\arrbdsse{\put ( 0.05,-0.1  ){\line( 1,-2){0.4}}}
\def\arrbdssw{\put (-0.05,-0.1  ){\line(-1,-2){0.4}}}
\def\arrbdwsw{\put (-0.15,-0.075){\line(-2,-1){0.7}}}
\def\arrbdwnw{\put (-0.15, 0.075){\line(-2, 1){0.7}}}
\def\arrbdnnw{\put (-0.05, 0.11 ){\line(-1, 2){0.4}}}

\def\arrhdnne(#1,#2){\put(#1,#2){\line(0,-1){0.056}}\put(#1,#2){\line(-3,-2){0.046}}}
\def\arrhdene(#1,#2){\put(#1,#2){\line(-1,0){0.056}}\put(#1,#2){\line(-2,-3){0.031}}}
\def\arrhdese(#1,#2){\put(#1,#2){\line(-1,0){0.056}}\put(#1,#2){\line(-2, 3){0.031}}}
\def\arrhdsse(#1,#2){\put(#1,#2){\line( 0,1){0.056}}\put(#1,#2){\line(-3, 2){0.046}}}
\def\arrhdssw(#1,#2){\put(#1,#2){\line( 0,1){0.056}}\put(#1,#2){\line( 3, 2){0.046}}}
\def\arrhdwsw(#1,#2){\put(#1,#2){\line( 1,0){0.056}}\put(#1,#2){\line( 2, 3){0.031}}}
\def\arrhdwnw(#1,#2){\put(#1,#2){\line( 1,0){0.056}}\put(#1,#2){\line( 2,-3){0.031}}}
\def\arrhdnnw(#1,#2){\put(#1,#2){\line(0,-1){0.056}}\put(#1,#2){\line( 3,-2){0.046}}}

%%%%%%%%% Long arrows
\def\longarrbdne{\put( 0.1, 0.1){\line( 1, 1){1.8}}}
\def\longarrbdse{\put( 0.1,-0.1){\line( 1,-1){1.8}}}
\def\longarrbdnw{\put(-0.1, 0.1){\line(-1, 1){1.8}}}
\def\longarrbdsw{\put(-0.1,-0.1){\line(-1,-1){1.8}}}
\def\longarrbdn{\put( 0,   0.1){\line( 0, 1){1.8}}}
\def\longarrbde{\put( 0.2, 0  ){\line( 1, 0){1.6}}}
\def\longarrbds{\put( 0,  -0.1){\line( 0,-1){1.8}}}
\def\longarrbdw{\put(-0.2, 0  ){\line(-1, 0){1.6}}}

\def\longarrbdnne{\put( 0.05, 0.1  ){\line( 1, 2){0.9}}}
\def\longarrbdene{\put( 0.15, 0.075){\line( 2, 1){1.7}}}
\def\longarrbdese{\put( 0.15,-0.075){\line( 2,-1){1.7}}}
\def\longarrbdsse{\put( 0.05,-0.1  ){\line( 1,-2){0.9}}}
\def\longarrbdssw{\put(-0.05,-0.1  ){\line(-1,-2){0.9}}}
\def\longarrbdwsw{\put(-0.15,-0.075){\line(-2,-1){1.7}}}
\def\longarrbdwnw{\put(-0.15, 0.075){\line(-2, 1){1.7}}}
\def\longarrbdnnw{\put(-0.05, 0.11 ){\line(-1, 2){0.9}}}

%%%%%%%%% Dotted Arrows
\def\arrddbdne{\multiput( 0.15, 0.15)( 0.1, 0.1){8}{\line( 1, 1){0.05}}}
\def\arrddbdse{\multiput( 0.15,-0.15)( 0.1,-0.1){8}{\line( 1,-1){0.05}}}
\def\arrddbdnw{\multiput(-0.15, 0.15)(-0.1, 0.1){8}{\line(-1, 1){0.05}}}
\def\arrddbdsw{\multiput(-0.15,-0.15)(-0.1,-0.1){8}{\line(-1,-1){0.05}}}
\def\arrddbdn{\multiput(  0,    0.15)( 0,   0.1){8}{\line( 0, 1){0.05}}}
\def\arrddbde{\multiput(  0.2,  0   )( 0.1, 0  ){6}{\line( 1, 0){0.05}}}
\def\arrddbds{\multiput(  0,   -0.15)( 0,  -0.1){8}{\line( 0,-1){0.05}}}
\def\arrddbdw{\multiput( -0.2,   0  )(-0.1, 0  ){6}{\line(-1, 0){0.05}}}

%%%%%%%%% Heads and tails.
% Heads; the argument determines where the apex of the arrow head lies.
\def\arrhdne(#1,#2){\put(#1,#2){\line(-1,-2){0.025}}\put(#1,#2){\line(-2,-1){0.05 }}}
\def\arrhdse(#1,#2){\put(#1,#2){\line(-1, 2){0.025}}\put(#1,#2){\line(-2, 1){0.05 }}}
\def\arrhdnw(#1,#2){\put(#1,#2){\line( 2,-1){0.05 }}\put(#1,#2){\line( 1,-2){0.025}}}
\def\arrhdsw(#1,#2){\put(#1,#2){\line( 2, 1){0.05 }}\put(#1,#2){\line( 1, 2){0.025}}}
\def\arrhdn(#1,#2){\put(#1,#2){\line( -1,-2){0.025}}\put(#1,#2){\line( 1,-2){0.025}}}
\def\arrhde(#1,#2){\put(#1,#2){\line( -2, 1){0.05 }}\put(#1,#2){\line(-2,-1){0.05 }}}
\def\arrhds(#1,#2){\put(#1,#2){\line( -1, 2){0.025}}\put(#1,#2){\line( 1, 2){0.025}}}
\def\arrhdw(#1,#2){\put(#1,#2){\line(  2, 1){0.05 }}\put(#1,#2){\line( 2,-1){0.05 }}}

% Drawing inclusion tails
\def\intaile{\put ( 0.2,   0.015){\oval(0.03,0.03)[l]}}
\def\intailn{\put (-0.015, 0.1  ){\oval(0.03,0.03)[b]}}
\def\intails{\put ( 0.015,-0.1  ){\oval(0.03,0.03)[t]}}
\def\intailw{\put (-0.2,   0.015){\oval(0.03,0.03)[r]}}

%%%%%%%%% Arrow Bodies, Heads and Tails
% The arguments are position (of the object from which to draw the arrow
% and the direction.

\def\body(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrbdn}
                                \or {\arrbdne}  \or {\arrbde}   \or {\arrbdse}
                                \or {\arrbds}   \or {\arrbdsw}  \or {\arrbdw}
                                \or {\arrbdnw}  \or {\arrbdnne} \or {\arrbdene}
                                \or {\arrbdese} \or {\arrbdsse} \or {\arrbdssw}
                                \or {\arrbdwsw} \or {\arrbdwnw} \or {\arrbdnnw} \fi}}

% General long arrow body command. The arguments are as above.
\def\longbody(#1,#2)#3{\put(#1,#2){\ifcase #3 {\longarrbdn}
        \or {\longarrbdne}  \or {\longarrbde}   \or {\longarrbdse}
        \or {\longarrbds}   \or {\longarrbdsw}  \or {\longarrbdw}
        \or {\longarrbdnw}  \or {\longarrbdnne} \or {\longarrbdene}
        \or {\longarrbdese} \or {\longarrbdsse} \or {\longarrbdssw}
        \or {\longarrbdwsw} \or {\longarrbdwnw} \or {\longarrbdnnw} \fi}}

% General short body. Arguments as above.
\def\shbody(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrshbdn}
                 \or {\arrshbdne}   \or {\arrshbde}   \or {\arrshbdse}
                 \or {\arrshbds}    \or {\arrshbdsw}  \or {\arrshbdw}
                 \or {\arrshbdnw}   \fi}}

% General dotted body.
\def\ddbody(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrddbdn}
                \or {\arrddbdne} \or {\arrddbde}  \or {\arrddbdse}
                \or {\arrddbds}  \or {\arrddbdsw} \or {\arrddbdw}
                \or {\arrddbdnw} \fi}}

% General plain head. Two arguments, postion and direction. The position is
% the object position from which the arrow emanates.
\def\plhead(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrhdn(0,0.9)}
                \or {\arrhdne(0.9,0.9)}       \or {\arrhde(0.8,0)}
                \or {\arrhdse(0.9,-0.9)}      \or {\arrhds(0,-0.9)}
                \or {\arrhdsw(-0.9,-0.9)}     \or {\arrhdw(-0.8,0)}
                \or {\arrhdnw(-0.9,0.9)}      \or {\arrhdnne(0.45,0.9)}
                \or {\arrhdene(0.85,0.425)}   \or {\arrhdese(0.85,-0.425)}
                \or {\arrhdsse(0.45,-0.9)}    \or {\arrhdssw(-0.45,-0.9)}
                \or {\arrhdwsw(-0.85,-0.425)} \or {\arrhdwnw(-0.85,0.425)}
                \or {\arrhdnnw(-0.45,0.9)}    \fi}}

% General long head. Two arguments, postion and direction. The position is
% the object position from which the arrow emanates.
\def\longplhead(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrhdn(0,1.9)}
                \or {\arrhdne(1.9,1.9)}       \or {\arrhde (1.8,0)}
                \or {\arrhdse(1.9,-1.9)}      \or {\arrhds(0,-1.9)}
                \or {\arrhdsw(-1.9,-1.9)}     \or {\arrhdw(-1.8,0)}
                \or {\arrhdnw(-1.9,1.9)}      \or {\arrhdnne(0.95,1.9)}
                \or {\arrhdene(1.85,0.925)}   \or {\arrhdese(1.85,-0.925)}
                \or {\arrhdsse(0.95,-1.9)}    \or {\arrhdssw(-0.95,-1.9)}
                \or {\arrhdwsw(-1.85,-0.925)} \or {\arrhdwnw(-1.85,0.925)}
                \or {\arrhdnnw(-0.95,1.9)}    \fi}}

% General double head. Arguments as above.
\def\dbhead(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrhdn(0,0.85)}
                \or {\arrhdne(0.85,0.85)}     \or {\arrhde(0.75,0)}
                \or {\arrhdse(0.85,-0.85)}    \or {\arrhds(0,-0.85)}
                \or {\arrhdsw(-0.85,-0.85)}   \or {\arrhdw(-0.75,0)}
                \or {\arrhdnw(-0.85,0.85)}    \fi}\plhead(#1,#2)#3}

% General tail. Arguments as above.
\def\tail(#1,#2)#3{\put(#1,#2){\ifcase #3 {\arrhdn(0,0.15)}
                \or {\arrhdne(0.15,0.15)}     \or {\arrhde(0.25,0)}
                \or {\arrhdse(0.15,-0.15)}    \or {\arrhds(0,-0.15)}
                \or {\arrhdsw(-0.15,-0.15)}   \or {\arrhdw(-0.25,0)}
                \or {\arrhdnw(-0.15,0.15)}    \fi}}

% !!! What the fuck is going on here ? (DVJM)
% General inclusion tail. Arguments as above.
\def\intail(#1,#2)#3{\put(#1,#2){\ifcase #3 {\intailn}
                \or                            \or {\intaile}
                \or                            \or {\intails}
                \or                            \or {\intailw} \fi}}

%%%%%%%%% Arrow labels.
% General "right hand" arrow labelling. Arguments are position, direction and label.
\def\arrlabelr(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                    {\put ( 0.05, 0.5  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.5,  0.4  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.5, -0.1  ){\makebox (0,0){$#4$}}}
                \or {\put ( 0.4, -0.5  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.05,-0.5  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.5,- 0.4  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.5,  0.1  ){\makebox (0,0){$#4$}}}
                \or {\put (-0.4,  0.5  ){\makebox(0,0)[l]{$#4$}}}
                \or {\put ( 0.3,  0.5  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.55, 0.175){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.5, -0.325){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.15,-0.55 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.3, -0.525){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.55,-0.175){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.5,  0.3  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.15, 0.55 ){\makebox (0,0)[l]{$#4$}}}  \fi}}

% General "left hand" arrow labelling. Arguments are position, direction
% and label.
\def\arrlabell(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                    {\put (-0.05, 0.5  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.4,  0.5  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.5,  0.1  ){\makebox (0,0){$#4$}}}
                \or {\put ( 0.5, -0.4  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.05,-0.5  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.4, -0.5  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.5, -0.1  ){\makebox (0,0){$#4$}}}
                \or {\put (-0.5,  0.4  ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.15, 0.55 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.5,  0.325){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.55,-0.175){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.3, -0.5  ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.15,-0.575){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.5, -0.325){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.55, 0.15 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.3,  0.5  ){\makebox (0,0)[r]{$#4$}}} \fi}}

% General "right hand" long arrow labelling.
\def\longarrlabelr(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                    {\put ( 0.05, 1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 1.1,  1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 1,   -0.1 ){\makebox (0,0){$#4$}}}
                \or {\put ( 0.9, -1   ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.05,-1   ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-1,   -0.9 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-1,    0.1 ){\makebox (0,0){$#4$}}}
                \or {\put (-0.9,  1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.55, 1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 1.05, 0.4 ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 1,   -0.55){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.4, -1.05){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.55,-1   ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-1.05,-0.4 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-1,    0.55){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.4,  1.05){\makebox (0,0)[l]{$#4$}}} \fi}}

% General "left hand" long arrow labelling.
\def\longarrlabell(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                    {\put (-0.05, 1   ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.9,  1   ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 1,    0.1 ){\makebox (0,0){$#4$}}}
                \or {\put ( 1,   -0.9 ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.05,-1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.9, -1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-1,   -0.1 ){\makebox (0,0){$#4$}}}
                \or {\put (-1,    0.9 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 0.4,  1.05){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 1,    0.55){\makebox (0,0)[r]{$#4$}}}
                \or {\put ( 1.05,-0.4 ){\makebox (0,0)[l]{$#4$}}}
                \or {\put ( 0.55,-1   ){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-0.4, -1.05){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-1,   -0.55){\makebox (0,0)[l]{$#4$}}}
                \or {\put (-1.05, 0.4 ){\makebox (0,0)[r]{$#4$}}}
                \or {\put (-0.55, 1   ){\makebox (0,0)[r]{$#4$}}}    \fi}}

%%%%%%%%%  Parallel and Antiparallel Arrows.
\def\prarrowe(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0,    0.05){\east}[#3][\po]
                                     \@plarrow( 0,   -0.05){\east}[#4][\st]}}
\def\prarrown(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.05, 0   ){\north}[#3][\po]
                                     \@plarrow( 0.05, 0   ){\north}[#4][\st]}}
\def\prarroww(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0,   -0.55){\west}[#3][\po]
                                     \@plarrow( 0,    0.55){\west}[#4][\st]}}
\def\prarrows(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.05, 0   ){\south}[#3][\po]
                                     \@plarrow(-0.05, 0   ){\south}[#4][\st]}}

\def\prarrone(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.03, 0.03){\neast}[#3][\po]
                                     \@plarrow( 0.03,-0.03){\neast}[#4][\st]}}
\def\prarronw(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.03,-0.03){\nwest}[#3][\po]
                                     \@plarrow( 0.03, 0.03){\nwest}[#4][\st]}}
\def\prarrose(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.03, 0.03){\seast}[#3][\po]
                                     \@plarrow(-0.03,-0.03){\seast}[#4][\st]}}
\def\prarrosw(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.03,-0.03){\swest}[#3][\po]
                                     \@plarrow(-0.03, 0.03){\swest}[#4][\st]}}

% Command for anti-parallel arrows. Arguments are position and labels.
\def\anprarrowe(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0,    0.05){\east}[#3][\po]
                                       \@plarrow( 1,   -0.05){\west}[#4][\po]}}
\def\anprarrown(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.05, 0   ){\north}[#3][\po]
                                       \@plarrow( 0.05, 1   ){\south}[#4][\po]}}
\def\anprarroww(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0,   -0.55){\west}[#3][\po]
                                       \@plarrow(-1,    0.55){\east}[#4][\po]}}
\def\anprarrows(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.05, 0   ){\south}[#3][\po]
                                       \@plarrow(-0.05,-1   ){\north}[#4][\po]}}

\def\prarrone(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.03, 0.03){\neast}[#3][\po]
                                     \@plarrow( 0.03,-0.03){\neast}[#4][\po]}}
\def\prarronw(#1,#2)#3#4{\put(#1,#2){\@plarrow(-0.03,-0.03){\nwest}[#3][\po]
                                     \@plarrow( 0.03, 0.03){\nwest}[#4][\po]}}
\def\prarrose(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.03, 0.03){\seast}[#3][\po]
                                     \@plarrow(-0.03,-0.03){\seast}[#4][\po]}}
\def\prarrosw(#1,#2)#3#4{\put(#1,#2){\@plarrow( 0.03,-0.03){\swest}[#3][\po]
                                     \@plarrow(-0.03, 0.03){\swest}[#4][\po]}}
% Main arrow drawing commands.
\def\plarrow(#1,#2)#3{\@ifnextchar[{\@plarrow(#1,#2){#3}}%
                                   {\@plarrow(#1,#2){#3}[][\po]}}
\def\@plarrow(#1,#2)#3[#4][#5]{\body(#1,#2){#3}\plhead(#1,#2){#3}
                                 {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                                  \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}

\def\longplarrow(#1,#2)#3{\@ifnextchar[{\@longplarrow(#1,#2){#3}}%
                                       {\@longplarrow(#1,#2){#3}[][\po]}}
\def\@longplarrow(#1,#2)#3[#4][#5]{\longbody(#1,#2){#3}\longplhead(#1,#2){#3}
                                     {\ifodd #5 {\longarrlabelr(#1,#2){#3}{#4}}
                                       \else     {\longarrlabell(#1,#2){#3}{#4}}\fi}}

\def\sharr(#1,#2)#3{\@ifnextchar[{\@sharr(#1,#2){#3}}%
                                 {\@sharr(#1,#2){#3}[][\po]}}
\def\@sharr(#1,#2)#3[#4][#5]{\shbody(#1,#2){#3}\plhead(#1,#2){#3}
                               {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                                \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}

\def\tlarrow(#1,#2)#3{\@ifnextchar[{\@tlarrow(#1,#2){#3}}%
                                   {\@tlarrow(#1,#2){#3}[][\po]}}
\def\@tlarrow(#1,#2)#3[#4][#5]{\shbody(#1,#2){#3}\plhead(#1,#2){#3}\tail(#1,#2){#3}
                                 {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                                  \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}

\def\dbarrow(#1,#2)#3{\@ifnextchar[{\@dbarrow(#1,#2){#3}}%
                                   {\@dbarrow(#1,#2){#3}[][\po]}}
\def\@dbarrow(#1,#2)#3[#4][#5]{\body(#1,#2){#3}\dbhead(#1,#2){#3}
                       {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                        \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}

\def\ddarrow(#1,#2)#3{\@ifnextchar[{\@ddarrow(#1,#2){#3}}%
                                   {\@ddarrow(#1,#2){#3}[][\po]}}
\def\@ddarrow(#1,#2)#3[#4][#5]{\ddbody(#1,#2){#3}\plhead(#1,#2){#3}
                                 {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                                  \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}

\def\inarrow(#1,#2)#3{\@ifnextchar[{\@inarrow(#1,#2){#3}}%
                                   {\@inarrow(#1,#2){#3}[][\po]}}
\def\@inarrow(#1,#2)#3[#4][#5]{\body(#1,#2){#3}\plhead(#1,#2){#3}\intail(#1,#2){#3}
                                 {\ifodd #5 {\arrlabelr(#1,#2){#3}{#4}}
                                   \else     {\arrlabell(#1,#2){#3}{#4}}\fi}}
\def\prarrow(#1,#2)#3{\@ifnextchar[{\@prarrow(#1,#2){#3}}%
                                   {\@prarrow(#1,#2){#3}[][\po]}}
\def\@prarrow(#1,#2)#3[#4][#5]{\ifcase #3 {\prarrown(#1,#2){#4}{#5}}
        \or {\prarrowne(#1,#2){#4}{#5}} \or {\prarrowe(#1,#2){#4}{#5}}
        \or {\prarrowse(#1,#2){#4}{#5}} \or {\prarrows(#1,#2){#4}{#5}}
        \or {\prarrowsw(#1,#2){#4}{#5}} \or {\prarroww(#1,#2){#4}{#5}}
        \or {\prarrownw(#1,#2){#4}{#5}} \fi}

\def\sharrow(#1,#2)#3{\@ifnextchar[{\@sharrow(#1,#2){#3}}%
                                   {\@sharrow(#1,#2){#3}[][\po]}}
\def\@sharrow(#1,#2)#3[#4][#5]{\ifcase #3
                                {\put( 0,   -0.05){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put(-0.05,-0.05){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put(-0.05, 0   ){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put(-0.05, 0.05){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put( 0,    0.05){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put( 0.05, 0.05){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put( 0.05, 0   ){\sharr(#1,#2){#3}[#4][#5]}}
                            \or {\put( 0.05,-0.05){\sharr(#1,#2){#3}[#4][#5]}} \fi}

\def\anprarrow(#1,#2)#3{\@ifnextchar[{\@anprarrow(#1,#2){#3}}%
                                     {\@anprarrow(#1,#2){#3}[][]}}
\def\@anprarrow(#1,#2)#3[#4][#5]{\ifcase #3 {\anprarrown(#1,#2){#4}{#5}}
                            \or {\@warning{Arrow style not available}}
                            \or {\anprarrowe(#1,#2){#4}{#5}}
                            \or {\@warning{Arrow style not available}}
                            \or {\anprarrows(#1,#2){#4}{#5}}
                            \or {\@warning{Arrow style not available}}
                            \or {\anprarroww(#1,#2){#4}{#5}}
                            \or {\@warning{Arrow style not available}} \fi}

%%%%%%%%% Curved arrow bodies and labels
\def\curvepoarrbdn#1{\put(-0.1, 0.1 ){\Curve(0,0.8){-5}}
                     \put(-0.3, 0.5 ){\makebox(0,0)[r]{$#1$}}}
\def\curvestarrbdn#1{\put( 0.1, 0.1 ){\Curve(0,0.8){5}}
                     \put( 0.3, 0.5 ){\makebox(0,0)[l]{$#1$}}}
\def\curvepoarrbde#1{\put( 0.2, 0.1 ){\Curve(0.6,0){-5}}
                     \put( 0.5, 0.3 ){\makebox(0,0.1){$#1$}}}
\def\curvestarrbde#1{\put( 0.2,-0.1 ){\Curve(0.6,0){5}}
                     \put( 0.5,-0.35){\makebox(0,0){$#1$}}}

\def\curvepoarrbds#1{\put( 0.1,-0.1){\Curve(0,-0.8){-5}}
                     \put( 0.3,-0.5){\makebox(0,0)[l]{$#1$}}}
\def\curvestarrbds#1{\put(-0.1,-0.1){\Curve(0,-0.8){5}}
                     \put(-0.3,-0.5){\makebox(0,0)[r]{$#1$}}}
\def\curvestarrbdw#1{\put(-0.2, 0.1){\Curve(-0.6,0){5}}
                     \put(-0.5, 0.3){\makebox(0,0.1){$#1$}}}
\def\curvepoarrbdw#1{\put(-0.2,-0.1){\Curve(-0.6,0){-5}}
                     \put(-0.5,-0.35){\makebox(0,0){$#1$}}}

% Long curved arrow bodies
\def\longcurvepoarrbdn#1{\put(-0.1, 0.1 ){\Curve(0,1.8){-5}}
                         \put(-0.6, 1   ){\makebox(0,0)[r]{$#1$}}}
\def\longcurvestarrbdn#1{\put( 0.1, 0.1 ){\Curve(0,1.8){5}}
                         \put( 0.6, 1   ){\makebox(0,0)[l]{$#1$}}}
\def\longcurvepoarrbde#1{\put( 0.2, 0.1 ){\Curve(1.6,0){-5}}
                         \put( 1,   0.55){\makebox(0,0){$#1$}}}
\def\longcurvestarrbde#1{\put( 0.2,-0.1 ){\Curve(1.6,0){5}}
                         \put( 1,  -0.6 ){\makebox(0,0){$#1$}}}
\def\longcurvepoarrbds#1{\put( 0.1,-0.1 ){\Curve(0,-1.8){-5}}
                         \put( 0.6,-1   ){\makebox(0,0)[l]{$#1$}}}
\def\longcurvestarrbds#1{\put(-0.1,-0.1 ){\Curve(0,-1.8){5}}
                         \put(-0.6,-1   ){\makebox(0,0)[r]{$#1$}}}
\def\longcurvestarrbdw#1{\put(-0.2, 0.1 ){\Curve(-1.6,0){5}}
                         \put(-1,   0.55){\makebox(0,0){$#1$}}}
\def\longcurvepoarrbdw#1{\put(-0.2,-0.1 ){\Curve(-1.6,0){-5}}
                         \put(-1., -0.6 ){\makebox(0,0){$#1$}}}

% Arrow heads for curved arrows
\let\curvepoarrhdn=\arrhdne
\let\curvestarrhdn=\arrhdnw
\let\curvepoarrhde=\arrhdse
\let\curvestarrhde=\arrhdne
\let\curvepoarrhds=\arrhdsw
\let\curvestarrhds=\arrhdse
\let\curvepoarrhdw=\arrhdsw
\let\curvestarrhdw=\arrhdnw

% General curved body
\def\curvepobody(#1,#2)#3#4{\put(#1,#2){\ifcase #3 {\curvepoarrbdn{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrbde{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrbds{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrbdw{#4}}
                        \or {\@warning{Arrow style not available}} \fi}}
\def\curvestbody(#1,#2)#3#4{\put(#1,#2){\ifcase #3 {\curvestarrbdn{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrbde{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrbds{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrbdw{#4}}
                        \or {\@warning{Arrow style not available}} \fi}}
\def\longcurvepobody(#1,#2)#3#4{\put(#1,#2){\ifcase #3 {\longcurvepoarrbdn{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvepoarrbde{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvepoarrbds{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvepoarrbdw{#4}}
                        \or {\@warning{Arrow style not available}} \fi}}

\def\longcurvestbody(#1,#2)#3#4{\put(#1,#2){\ifcase #3 {\longcurvestarrbdn{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvestarrbde{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvestarrbds{#4}}
                        \or {\@warning{Arrow style not available}}
                        \or {\longcurvestarrbdw{#4}}
                        \or {\@warning{Arrow style not available}} \fi}}

\def\curvepohead(#1,#2)#3{\put(#1,#2) {\ifcase #3 {\curvepoarrhdn(-0.1,0.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhde(0.8,0.1)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhds(0.1,-0.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhdw(-0.8,-0.1)}
                        \or {\@warning{Arrow style not available}} \fi}}

\def\curvesthead(#1,#2)#3{\put(#1,#2) {\ifcase #3 {\curvestarrhdn(0.1,0.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrhde(0.8,-0.1)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrhds(-0.1,-0.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvestarrhdw(-0.8,0.1)}
                        \or {\@warning{Arrow style not available}} \fi}}

\def\longcurvepohead(#1,#2)#3{\put(#1,#2) {\ifcase #3 {\curvepoarrhdn(-0.1,1.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhde(1.8,0.1)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhds(0.1,-1.9)}
                        \or {\@warning{Arrow style not available}}
                        \or {\curvepoarrhdw(-1.8,-0.1)}
                        \or {\@warning{Arrow style not available}} \fi}}

\def\longcurvesthead(#1,#2)#3{\put(#1,#2) {\ifcase #3 {\curvestarrhdn(0.1,1.9)}
                                \or {\@warning{Arrow style not available}}
                                \or {\curvestarrhde(1.8,-0.1)}
                                \or {\@warning{Arrow style not available}}
                                \or {\curvestarrhds(-0.1,-1.9)}
                                \or {\@warning{Arrow style not available}}
                                \or {\curvestarrhdw(-1.8,0.1)}
                                \or {\@warning{Arrow style not available}} \fi}}

\def\curvepoarrow(#1,#2)#3#4{\curvepobody(#1,#2){#3}{#4}\curvepohead(#1,#2){#3}}
\def\curvestarrow(#1,#2)#3#4{\curvestbody(#1,#2){#3}{#4}\curvesthead(#1,#2){#3}}

\def\longcurvepoarrow(#1,#2)#3#4{\longcurvepobody(#1,#2){#3}{#4}%
                                 \longcurvepohead(#1,#2){#3}}
\def\longcurvestarrow(#1,#2)#3#4{\longcurvestbody(#1,#2){#3}{#4}%
                                 \longcurvesthead(#1,#2){#3}}

\def\curvearrow(#1,#2)#3{\@ifnextchar[{\@curvearrow(#1,#2){#3}}%
                                      {\@curvearrow(#1,#2){#3}[]}}
\def\@curvearrow(#1,#2)#3[#4]#5{\ifodd #5 {\curvestarrow(#1,#2){#3}{#4}}
                                \else     {\curvepoarrow(#1,#2){#3}{#4}}     \fi}

\def\longcurvearrow(#1,#2)#3{\@ifnextchar[{\@longcurvearrow(#1,#2){#3}}%
                                          {\@longcurvearrow(#1,#2){#3}[]}}
\def\@longcurvearrow(#1,#2)#3[#4]#5{\ifodd #5 {\longcurvestarrow(#1,#2){#3}{#4}}
                                    \else     {\longcurveporrow(#1,#2){#3}{#4}} \fi}

%%%%%%% Two cells
\def\twocellup(#1,#2){\put(#1,#2){{\put( 0.02,-0.1) {\line( 0, 1) {0.16}}}
                                  {\put(-0.02,-0.1) {\line( 0, 1) {0.16}}}
                                  {\put( 0,    0.1) {\line( 1,-2) {0.05}}}
                                  {\put( 0,    0.1) {\line(-1,-2) {0.05}}}}}

\def\twocelldown(#1,#2){\put(#1,#2){{\put( 0.02, 0.1) {\line( 0,-1) {0.16}}}
                                    {\put(-0.02, 0.1) {\line( 0,-1) {0.16}}}
                                    {\put( 0,   -0.1) {\line( 1, 2) {0.05}}}
                                    {\put( 0,   -0.1) {\line(-1, 2) {0.05}}}}}

\def\twocellright(#1,#2){\put(#1,#2){{\put(-0.1, 0.02) {\line( 1, 0){0.16}}}
                                     {\put(-0.1,-0.02) {\line( 1, 0){0.16}}}
                                     {\put( 0.1, 0   ) {\line(-2, 1){0.1 }}}
                                     {\put( 0.1, 0   ) {\line(-2,-1){0.1 }}}}}

\def\twocellleft(#1,#2){\put(#1,#2){{\put( 0.1,-0.02) {\line(-1, 0) {0.16}}}
                                    {\put( 0.1, 0.02) {\line(-1, 0) {0.16}}}
                                    {\put(-0.1, 0   ) {\line( 2,-1) {0.1 }}}
                                    {\put(-0.1, 0   ) {\line( 2, 1) {0.1 }}}}}

\def\twocellclock(#1,#2)#3{\put(#1,#2){\ifcase #3 {\twocellright(0,   0.5)}
                \or               \or {\twocelldown( 0.5, 0  )}
                \or               \or {\twocellleft( 0,  -0.5)}
                \or               \or {\twocellup(  -0.5, 0  )}
                \or               \or {\twocellright(0.25,0.6)}
                \or {\twocelldown(  0.6,  0.25)}
                \or {\twocelldown(  0.6, -0.25)}
                \or {\twocellleft(  0.25,-0.6 )}
                \or {\twocellleft( -0.25,-0.6 )}
                \or {\twocellup(   -0.6, -0.25)}
                \or {\twocellup   (-0.6,  0.25)}
                \or {\twocellright(-0.25, 0.6 )} \fi}}

\def\twocellanti(#1,#2)#3{\put(#1,#2){\ifcase #3 {\twocellleft(  0,   0.5)}
                \or               \or {\twocellup(   0.5, 0  )}
                \or               \or {\twocellright(0,  -0.5)}
                \or               \or {\twocelldown(-0.5, 0  )}
                \or               \or {\twocellleft( 0.25,0.6)}
                \or {\twocellup(    0.6,  0.25)}
                \or {\twocellup(    0.6, -0.25)}
                \or {\twocellright( 0.25,-0.6)}
                \or {\twocellright(-0.25,-0.6)}
                \or {\twocelldown( -0.6, -0.25)}
                \or {\twocelldown( -0.6,  0.25)}
                \or {\twocellleft( -0.25, 0.6)} \fi}}

\def\twocelllabelfar(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                                    {\put( 0,    0.65){\makebox(0,0){$#4$}}}
                \or             \or {\put( 0.6,  0   ){\makebox(0,0)[l]{$#4$}}}
                \or             \or {\put( 0,   -0.65){\makebox(0,0){$#4$}}}
                \or             \or {\put(-0.6,  0   ){\makebox(0,0)[r]{$#4$}}}
                \or             \or {\put( 0.25, 0.75){\makebox(0,0){$#4$}}}
                                \or {\put( 0.7,  0.25){\makebox(0,0)[l]{$#4$}}}
                                \or {\put( 0.7, -0.25){\makebox(0,0)[l]{$#4$}}}
                                \or {\put( 0.25,-0.75){\makebox(0,0){$#4$}}}
                                \or {\put(-0.25,-0.75){\makebox(0,0){$#4$}}}
                                \or {\put(-0.7, -0.25){\makebox(0,0)[r]{$#4$}}}
                                \or {\put(-0.7,  0.25){\makebox(0,0)[r]{$#4$}}}
                                \or {\put(-0.25, 0.75){\makebox(0,0){$#4$}}}  \fi}}

\def\twocelllabelnear(#1,#2)#3#4{\put(#1,#2){\ifcase #3
                                     {\put( 0,    0.35){\makebox(0,0){$#4$}}}
                                 \or
                                 \or {\put( 0.4,  0   ){\makebox(0,0)[r]{$#4$}}}
                                 \or
                                 \or {\put( 0,   -0.35){\makebox(0,0){$#4$}}}
                                 \or
                                 \or {\put(-0.4,  0   ){\makebox(0,0)[l]{$#4$}}}
                                 \or
                                 \or {\put( 0.25, 0.45){\makebox(0,0){$#4$}}}
                                 \or {\put( 0.5,  0.25){\makebox(0,0)[r]{$#4$}}}
                                 \or {\put( 0.5, -0.25){\makebox(0,0)[r]{$#4$}}}
                                 \or {\put( 0.25,-0.45){\makebox(0,0){$#4$}}}
                                 \or {\put(-0.25,-0.45){\makebox(0,0){$#4$}}}
                                 \or {\put(-0.5, -0.25){\makebox(0,0)[l]{$#4$}}}
                                 \or {\put(-0.5,  0.25){\makebox(0,0)[l]{$#4$}}}
                                 \or {\put(-0.25, 0.45){\makebox(0,0){$#4$}}} \fi}}

\def\twocell(#1,#2)#3#4{\@ifnextchar[{\@twocell(#1,#2){#3}{#4}}%
                                     {\@twocell(#1,#2){#3}{#4}[][\far]}}
\def\@twocell(#1,#2)#3#4[#5][#6]{{\ifcase #4 {\twocellclock(#1,#2){#3}}
                                  \or        {\twocellanti(#1,#2){#3}}          \fi}
                                 {\ifcase #6 {\twocelllabelnear(#1,#2){#3}{#5}}
                                  \or        {\twocelllabelfar(#1,#2){#3}{#5}}  \fi}}


%%%%%%% The flexi--arrow routines
\def\Farrow(#1,#2)(#3,#4){\@ifnextchar[{\@Garrow(#1,#2)(#3,#4)}%
                                       {\@Farrow(#1,#2)(#3,#4)[][\po]}}

% Note (1) that the \put(0,0) really is necessary, and (2) that
% the overhead of doing the trig. means it really is worth avoiding for G
\def\@Farrow(#1,#2)(#3,#4)[#5][#6]{\put(0,0){\@GenLab{#1}{#2}{#3}{#4}{#5}{#6}}
                           \put(0,0){\@FlArrow(#1,#2)(#3,#4)(0.15,0.15)(0.15,0.15)}}
\def\@Garrow(#1,#2)(#3,#4)[#5][#6]{%
                      \put(0,0){\@FlArrow(#1,#2)(#3,#4)(0.15,0.15)(0.15,0.15)}}
% In the course of time, @GenLab will label an arrow at arbitrary slope.
\def\@GenLab#1#2#3#4#5#6{}
%     \dimen0 = #1pt
%     \dimen1 = #2pt
%     \dimen3 = #3pt
%     \dimen4 = #4pt
%     \advance \dimen3 by -\dimen1
%     \advance \dimen4 by -\dimen2

% Essentially, we need to work out dx + h sin p, dy + h cos p, where dx
% is x1 - x0, dy similarly, p is atan (dy/dx) and h is about 10pt.
% The arguments are: #1 = x0, #2 = y0, #3 = x1, #4 = y1, #5 = label, #6 = direction
% One for \po first.

% \input ArcTan.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\endinput
%
% end of diagram.sty