% lamsarrow.sty: fancy arrows using lams fonts
% Author: extracted from Michael Spivak's LamS-TeX by Paul Burchard
% Version Number: 4.1
% Version Date: 24 Jan 1997
%
%--------------------- LamS-TeX copyright -------------------------
% COPYRIGHT (C) 1989, 1990, 1991 by the Texplorators Corporation,
% 1572 West Gray #377, Houston, TX 77019-4948 (ALL RIGHTS RESERVED)
%------------------------------------------------------------------
%
% This macro package allows LaTeX users to make use of the LamS-TeX
% arrow fonts and create arrows with
%	* any valid LaTeX \line slope (unlike LaTeX's \vector)
%	* all those fancy head/tail symbols and shaft styles.
%
% Actually, these macros will accept any slope and approximate it
% by the closest LaTeX \line slope.  In making the approximation
% to the desired arrow slope, these macros will work to keep the
% arrow's *vertical* dimension accurate (at the expense
% of the horizontal one, if necessary).  This requires the
% opposite strategy from LaTeX's \line and \vector commands,
% where the *horizontal* dimension can always be precisely
% specified.
%
% The macros seem to have the 10pt font size hardcoded in, so
% the arrow embellishments will be on the marginally small side
% in 12pt.
%
% Commands defined in this style file:
%
% \lamsarrow(#1,#2)
%	Draws an arrow which extends #1 \unitlengths in the
%	x-direction and #2 \unitlengths in the y-direction from the
%	current position.  #1 and #2 are arbitrary real numbers,
%	not both zero.  Intended for use in the picture environment.
%
% \lamsvector(#1,#2){#3}
%	Has the same effect as \lamsarrow, except its usage is
%	completely compatible with LaTeX's \vector command.  But
%	with \lamsvector, there are no limits on the size of the
%	integers #1, #2, and it is OK if they have common factors.
%	Only valid LaTeX line slopes will actually be drawn, tho.
%
% \lamsshaft{#1}
%	A local declaration which changes the style of the shaft
%	of any subsequent lams arrows within the same environment
%	or {...} group.  The symbol #1 may be one of:
%
%		-	solid line (default)
%		.	dashed line
%		=	long equals sign (no head or tail printed)
%		0	invisible arrow
%		?	reset to default
%
% \lamssource{#1}
% \lamstarget{#1}
%	Local declarations which change the symbol placed at the
%	initial and final points, respectively, of the arrow shaft.
%	Affects subsequent lams arrows within the same environment
%	or {...} group.  For either declaration, the symbol #1 may
%	be any one of:
%
%	  Heads:
%		^	arrow head (default for \lamstarget)
%		V	arrow tail (default for \lamssource)
%		'	left half of arrowhead
%		`	right half of arrowhead
%		A	double arrowhead
%	  Tails:
%		J	left fishhook tail
%		L	right fishhook tail
%		S	squiggle
%	  Other:
%		0	no symbol
%		?	reset to default
%

% detente message
\typeout{ * LAMSTEX ARROWS *                                      }
\typeout{ The arrows you are using are courtesy of LamS-TeX, a    }
\typeout{ full-featured mathematical typsetting package which its }
\typeout{ creator, at least, believes to be superior to LaTeX.    }
\typeout{ You can obtain LamS-TeX by anonymous FTP from most TeX  }
\typeout{ archives, or through the TUG user group organization.   }
\typeout{ }

% lams arrow fonts
\font\lamsfont@i=lams1
\font\lamsfont@ii=lams2
\font\lamsfont@iii=lams3
\font\lamsfont@iv=lams4
\font\lamsfont@v=lams5

% arrow geom params
% direction
\newif\ifN@
\newif\ifE@
\newif\ifNESW@
\newif\ifH@
\newif\ifV@
% location of source, target
\newdimen\lams@firstx
\newdimen\lams@firsty
\newdimen\lams@lastx
\newdimen\lams@lasty
\newdimen\lams@center %ignore
% shaft char dims
\newdimen\lams@ht
\newdimen\lams@wd

% misc
\newcount\ten@ \ten@10


%%%%%%%%%%%%%%%%%%%% \lamssource, \lamstarget, \lamsshaft
%
% Used to set arrow style options.
%
% EXTERNAL VARS COMPUTED
%
% \lams@source \lams@target \lams@shaft

\newcount\lams@source
\newcount\lams@target
\newcount\lams@shaft

\def\lamssource#1{%
 \if#10\lams@source\m@ne\else
 \if#1?\lams@source\z@\else
 \if#1V\lams@source\tw@\else
 \if#1^\lams@source\thr@@\else
 \if#1'\lams@source6 \else
 \if#1`\lams@source7 \else
 \if#1J\lams@source8 \else
 \if#1L\lams@source9 \else
 \if#1S\lams@source12 \else
 \if#1A\lams@source13 \else
 \@latexerr{Invalid lamsarrow source style: #1}%
 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
\def\lamstarget#1{%
 \if#10\lams@target\m@ne\else
 \if#1?\lams@target\z@\else
 \if#1^\lams@target\tw@\else
 \if#1V\lams@target\thr@@\else
 \if#1'\lams@target4 \else
 \if#1`\lams@target5 \else
 \if#1J\lams@target\ten@ \else
 \if#1L\lams@target11 \else
 \if#1S\lams@target12 \else
 \if#1A\lams@target13 \else
 \@latexerr{Invalid lamsarrow target style: #1}%
 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
\def\lamsshaft#1{%
 \if#10\lams@shaft\m@ne\else
 \if#1?\lams@shaft\z@\else
 \if#1-\lams@shaft\@ne\else
 \if#1.\lams@shaft\tw@\else
 \if#1=\lams@shaft\thr@@\else
 \@latexerr{Invalid lamsarrow shaft style: #1}%
 \fi\fi\fi\fi\fi}


%%%%%%%%%%%%%%%%%%%% \lams@slope
%
% Utility macro to calculate arrow shaft character in lamstex arrow
% fonts, given the x- and y-dimensions of the raw arrow.
%
% EXTERNAL VARS USED
%
% \lams@firstx \lams@lastx \lams@firsty \lams@lasty
% \ifN@ \ifE@
%
% EXTERNAL VARS COMPUTED
%
% \lams@tani \lams@tanii \lams@ang
%
% INTERNAL VARS USED
%
% \lams@slopei \lams@slopeii
% \lams@tanip \lams@taniip \lams@slopeip \lams@slopeiip
% \count@ \lams@extra

\newcount\lams@tani
\newcount\lams@tanip
\newcount\lams@tanii
\newcount\lams@taniip
\newdimen\lams@slopei
\newdimen\lams@slopeip
\newdimen\lams@slopeii
\newdimen\lams@slopeiip
\newcount\lams@ang
\newcount\lams@extra

\def\lams@slopeselect{%
 \\161\\152\\143\\134\\255\\126\\357\\238\\349\\45{10}%
 \\56{11}\\11{12}\\65{13}\\54{14}\\43{15}\\32{16}\\53{17}%
 \\21{18}\\52{19}\\31{20}\\41{21}\\51{22}\\61{23}}

\def\lams@slope{{\lams@slopei\lams@lasty
 \advance\lams@slopei-\lams@firsty
 \ifN@\else\multiply\lams@slopei\m@ne\fi
 \lams@slopeii\lams@lastx\advance\lams@slopeii-\lams@firstx
 \ifE@\else\multiply\lams@slopeii\m@ne\fi
 \ifdim\lams@slopeii<\z@
  \global\lams@tani6 \global\lams@tanii\@ne\global\lams@ang23
 \else
  \dimen@\lams@slopei\multiply\dimen@6
  \ifdim\dimen@<\lams@slopeii
   \global\lams@tani\@ne\global\lams@tanii6 \global\lams@ang\@ne
  \else
   \dimen@\lams@slopeii\multiply\dimen@6
   \ifdim\dimen@<\lams@slopei
    \global\lams@tani6 \global\lams@tanii\@ne\global\lams@ang23
   \else
    \global\lams@tanip\z@\global\lams@taniip\@ne
    \def\\##1##2##3{\global\lams@ang##3\relax
     \lams@slopeip\lams@slopei\lams@slopeiip\lams@slopeii
     \multiply\lams@slopeiip##1\relax
     \multiply\lams@slopeip##2\relax
     \ifdim\lams@slopeiip<\lams@slopeip
      \global\lams@tanip##1\relax\global\lams@taniip##2\relax
     \else
      \global\lams@tani##1\relax\global\lams@tanii##2\relax
      \def\\####1####2####3{}%
     \fi}%
    \lams@slopeselect
    \lams@slopei\lams@lasty\advance\lams@slopei-\lams@firsty
    \ifN@\else\multiply\lams@slopei\m@ne\fi
    \multiply\lams@slopei\lams@tanii
    \multiply\lams@slopei\lams@taniip
    \multiply\lams@slopei\tw@
    \count@\lams@tani\multiply\count@\lams@taniip
    \lams@extra\lams@tanip\multiply\lams@extra\lams@tanii
    \advance\count@\lams@extra
    \lams@slopeii\lams@lastx\advance\lams@slopeii-\lams@firstx
    \ifE@\else\multiply\lams@slopeii\m@ne\fi
    \multiply\lams@slopeii\count@
    \ifdim\lams@slopei<\lams@slopeii
     \global\lams@tani\lams@tanip\global\lams@tanii\lams@taniip
     \global\advance\lams@ang\m@ne
    \fi
   \fi
  \fi
 \fi}%
}


%%%%%%%%%%%%%%%%%%%% \lamsarrow, \lamsvector
%
% User macros for lams arrows.  They call \lams@arrow, which sets
% up parameters for \lams@harrow, \lams@varrow, and \lams@darrow.
%
% EXTERNAL VARS USED
%
% \lams@source \lams@target
%
% EXTERNAL VARS COMPUTED
%
% \ifNESW@ \ifN@ \ifE@
% \lams@center \lams@firstx \lams@firsty \lams@lasty
% \lams@wd \lams@ht
%
% INTERNAL VARS USED
%
% \lams@xsize \lams@ysize

\newdimen\lams@xsize
\newdimen\lams@ysize

\def\lamsvector(#1,#2)#3{%
 \lams@xsize#3\unitlength\relax
 \ifnum#1<\z@\multiply\lams@xsize\m@ne\fi
 \lams@ysize\lams@xsize
 \ifnum#1=\z@
  \lams@xsize\z@
  \ifnum#2<\z@\multiply\lams@ysize\m@ne\fi
 \else
  \multiply\lams@ysize#2\relax\divide\lams@ysize#1\relax
 \fi
 \lams@arrow{\lams@xsize}{\lams@ysize}%
}

\def\lamsarrow(#1,#2){%
 \lams@xsize#1\unitlength\relax\lams@ysize#2\unitlength\relax
 \lams@arrow{\lams@xsize}{\lams@ysize}%
}

\def\lams@switchsides{%
  \ifnum\lams@source=6\relax\lams@source7\else
  \ifnum\lams@source=7\relax\lams@source6\else
  \ifnum\lams@source=8\relax\lams@source9\else
  \ifnum\lams@source=9\relax\lams@source8\fi\fi\fi\fi\relax
  \ifnum\lams@target=4\relax\lams@target5\else
  \ifnum\lams@target=5\relax\lams@target4\else
  \ifnum\lams@target=\ten@\relax\lams@target11\else
  \ifnum\lams@target=11\relax\lams@target\ten@\fi\fi\fi\fi\relax
}

\def\lams@arrow#1#2{%
 \lams@firstx\z@\lams@firsty\z@
 \lams@lastx#1\relax\lams@lasty#2\relax
 \lams@center\z@
 %
 % compute direction flags
 \N@false\E@false\H@false\V@false
 \ifdim\lams@lastx>\z@\E@true\fi
 \ifdim\lams@lastx=\z@\V@true\fi
 \ifdim\lams@lasty>\z@\N@true\fi
 \ifdim\lams@lasty=\z@\H@true\fi
 \NESW@false
 \ifN@\ifE@\NESW@true\fi\else\ifE@\else\NESW@true\fi\fi
 %
 % fix up one-sided embellishments, depending on direction
 \ifdim\lams@lastx<\z@ \lams@switchsides \fi
 \ifdim\lams@lastx=\z@ \ifdim\lams@lasty<\z@ \lams@switchsides \fi\fi
 %
 % compute shaft char info with help of \lams@slope macro 
 \ifH@\else\ifV@\else
  \lams@slope
  \ifnum\lams@tani>\lams@tanii
   \lams@ht\ten@\p@\lams@wd\ten@\p@
   \multiply\lams@wd\lams@tanii\divide\lams@wd\lams@tani
  \else
   \lams@wd\ten@\p@\lams@ht\ten@\p@
   \divide\lams@ht\lams@tanii\multiply\lams@ht\lams@tani
  \fi
 \fi\fi
 %
 % adjust arrow placement for source and target style
 \ifH@\else\ifV@\else
  \ifnum\lams@target=\thr@@
   \ifN@\advance\lams@lasty-.3\lams@ht
   \else\advance\lams@lasty.3\lams@ht\fi
  \fi
  \ifnum\lams@source=\tw@
   \ifE@\advance\lams@firstx.3\lams@ht
   \else\advance\lams@firstx-.3\lams@ht\fi
  \fi
  \ifnum\lams@target=12
   \ifN@\advance\lams@lasty-\lams@ht
   \else\advance\lams@lasty\lams@ht\fi
  \fi
 \fi\fi
 %
 % draw arrow, special-casing horizontal and vertical ones
 \ifH@  \lams@harrow
 \else\ifV@ \lams@varrow
 \else \lams@darrow
 \fi\fi
}


%%%%%%%%%%%%%%%%%%%% \lams@darrow
%
% Does actual drawing of diagonal arrows,
% with the help of \lams@cos.
%
% EXTERNAL VARS USED
%
% \lams@shaft \lams@source \lams@target
%
% \ifNESW@ \ifN@ \ifE@ (computed by \lams@arrow)
% \lams@center \lams@firstx \lams@firsty \lams@lasty (ibid)
% \lams@wd \lams@ht (computed by \lams@arrow)
%
% \lams@ang \lams@tani \lams@tanii (computed by \lams@slope)
%
% \lamsfont@i \lamsfont@ii \lamsfont@iii \lamsfont@iv \lamsfont@v
%
% INTERNAL VARS USED
%
% \lams@sl (from \lams@ang, used by \lams@cos)
% \lams@S \lams@T (from \lams@ang, \lams@source, \lams@target)
% \lams@shift (+/- \lams@firsty) \lams@adj
% \lams@goal (+/-(\lams@lasty-\lams@firsty))
% \dimen@ \dimen@ii \count@ (computed by \lams@cos)
% \arrowfont@ \lams@shaftbox \lams@ZERO

\newdimen\lams@goal
\newdimen\lams@shift
\newdimen\lams@adj
\newcount\lams@T
\newcount\lams@S
\newbox\lams@shaftbox
\newcount\lams@sl
\newbox\lams@ZERO

\def\lams@next{\ifN@\let\next@\raise\else\let\next@\lower\fi}

\def\lams@cos#1{%
 \ifnum\lams@tani<\lams@tanii
  \dimen@#1%
  \ifnum\lams@sl<8 \count@9
  \else \ifnum\lams@sl<12 \count@8
  \else \count@7 \fi\fi
  \multiply\dimen@\count@\divide\dimen@\ten@
  \dimen@ii\dimen@\multiply\dimen@ii\lams@tani
  \divide\dimen@ii\lams@tanii
 \else
  \dimen@ii#1%
  \count@-\lams@sl\advance\count@24
  \ifnum\count@<8 \count@9 \else \ifnum\count@<12 \count@8
   \else\count@7 \fi\fi
  \multiply\dimen@ii\count@\divide\dimen@ii\ten@
  \dimen@\dimen@ii\multiply\dimen@\lams@tanii
  \divide\dimen@\lams@tani
 \fi
}

\def\lams@darrow{\lams@sl\lams@ang
 \ifNESW@
  \ifnum\lams@ang<\ten@
   \let\arrowfont@\lamsfont@i\global\advance\lams@ang\m@ne
   \global\multiply\lams@ang13
  \else
   \ifnum\lams@ang<19
    \let\arrowfont@\lamsfont@ii\global\advance\lams@ang-\ten@
    \global\multiply\lams@ang13
   \else
    \let\arrowfont@\lamsfont@iii\global\advance\lams@ang-19
    \global\multiply\lams@ang13
  \fi\fi
  \lams@T\lams@ang
 \else
  \ifnum\lams@ang<5
   \let\arrowfont@\lamsfont@iii\global\advance\lams@ang\m@ne
   \global\multiply\lams@ang13 \global\advance\lams@ang65
  \else
   \ifnum\lams@ang<14
    \let\arrowfont@\lamsfont@iv\global\advance\lams@ang-5
    \global\multiply\lams@ang13
   \else
    \ifnum\lams@ang<23
     \let\arrowfont@\lamsfont@v\global\advance\lams@ang-14
     \global\multiply\lams@ang13
    \else
     \let\arrowfont@\lamsfont@i\global\lams@ang117
  \fi\fi\fi
  \ifnum\lams@ang=117 \lams@T115 \else\lams@T\lams@ang\fi
 \fi
 \lams@S\lams@T
 \ifE@
  \ifnum\lams@target=\z@\advance\lams@T\tw@
  \else\ifnum\lams@target=13 \advance\lams@T\tw@
  \else\advance\lams@T\lams@target\fi\fi
  \ifnum\lams@source=\z@
  \else\ifnum\lams@source=13 \advance\lams@S\thr@@
  \else\advance\lams@S\lams@source\fi\fi
 \else
  \ifcase\lams@target\advance\lams@T\thr@@\or
   \or\advance\lams@T\thr@@\or
   \advance\lams@T\tw@\or\advance\lams@T6 \or\advance\lams@T7
   \or\or\or\or\or\advance\lams@T8 \or\advance\lams@T9 \or
   \advance\lams@T12 \or\advance\lams@T\thr@@\fi
  \ifcase\lams@source\or\or\advance\lams@S\thr@@
   \or\advance\lams@S\tw@\or\or\or\advance\lams@S4 
   \or\advance\lams@S5 \or\advance\lams@S\ten@
   \or\advance\lams@S11 \or\or\or\advance\lams@S12
   \or\advance\lams@S\tw@\fi
 \fi
 \ifcase\lams@shaft\or\or\global\advance\lams@ang\@ne\else\fi
 \ifN@\lams@shift\lams@firsty\else\lams@shift-\lams@firsty\fi
 \ifE@\else\advance\lams@shift\lams@ht\fi
 \lams@goal\lams@lasty\advance\lams@goal-\lams@firsty
 \ifN@\else\multiply\lams@goal\m@ne\fi
 \setbox\lams@shaftbox\hbox{\arrowfont@\char\lams@ang}%
 \ifnum\lams@shaft=\thr@@
  \lams@cos{1.5\p@}%
  \setbox\lams@shaftbox\hbox to\wd\lams@shaftbox{\arrowfont@
   \rlap{\hskip\dimen@ii
    \smash{\ifNESW@\let\next@\lower\else\let\next@\raise\fi
     \next@\dimen@\hbox{\arrowfont@\char\lams@ang}}}%
   \rlap{\hskip-\dimen@ii
    \smash{\ifNESW@\let\next@\raise\else\let\next@\lower\fi
      \next@\dimen@\hbox{\arrowfont@\char\lams@ang}}}\hfil}%
 \fi
 \rlap{\smash{\hskip\lams@center\hskip\lams@firstx
  \ifnum\lams@shaft=\m@ne
  \else
   \ifnum\lams@shaft=\thr@@
   \else
    \ifnum\lams@source=\m@ne
    \else
     \ifnum\lams@source=\z@
     \else
      \setbox\lams@ZERO\hbox{%
       \ifnum\lams@ang=117 \lamsfont@v\else\arrowfont@\fi
       \char\lams@S}%
      \ifNESW@
       \ifnum\lams@source=\tw@
        \dimen@\lams@shift\advance\dimen@-\lams@ht
        \ifN@\hskip-\wd\lams@ZERO\fi
        \lams@next
        \next@\dimen@\copy\lams@ZERO
        \ifN@\else\hskip-\wd\lams@ZERO\fi
       \else
        \lams@next
        \ifN@\else\hskip-\wd\lams@ZERO\fi
        \next@\lams@shift\copy\lams@ZERO
        \ifN@\hskip-\wd\lams@ZERO\fi
       \fi
       \ifnum\lams@source=12
        \advance\lams@shift\lams@ht\advance\lams@goal-\lams@ht
        \ifN@\hskip\wd\lams@ZERO\else\hskip-\wd\lams@ZERO\fi
       \fi
       \ifnum\lams@source=13
        \lams@cos{\thr@@\p@}%
        \ifN@\hskip\dimen@\else\hskip-\wd\lams@ZERO\hskip-\dimen@\fi
        \lams@adj\lams@shift\advance\lams@adj\dimen@ii
        \lams@next
        \next@\lams@adj\copy\lams@ZERO
        \ifN@\hskip-\dimen@\hskip-\wd\lams@ZERO\else\hskip\dimen@\fi
       \fi
      \else
       \ifN@\hskip-\wd\lams@ZERO\fi
       \ifnum\lams@source=\tw@
        \ifN@\hskip\wd\lams@ZERO\else\hskip-\wd\lams@ZERO\fi
        \dimen@\lams@shift\advance\dimen@-\lams@ht
        \lams@next
        \next@\dimen@\copy\lams@ZERO
        \ifN@\hskip-\wd\lams@ZERO\fi
       \else
        \lams@next
        \next@\lams@shift\copy\lams@ZERO
        \ifN@\else\hskip-\wd\lams@ZERO\fi
       \fi
       \ifnum\lams@source=12
        \advance\lams@shift\lams@ht\advance\lams@goal-\lams@ht
        \ifN@\hskip-\wd\lams@ZERO\else\hskip\wd\lams@ZERO\fi
       \fi
       \ifnum\lams@source=13
        \lams@cos{\thr@@\p@}%
        \ifN@\hskip-\wd\lams@ZERO\hskip-\dimen@\else\hskip\dimen@\fi
        \lams@adj\lams@shift\advance\lams@adj\dimen@ii
        \lams@next
        \next@\lams@adj\copy\lams@ZERO
        \ifN@\hskip\dimen@\else\hskip-\dimen@\hskip-\wd\lams@ZERO\fi
       \fi
      \fi
  \fi\fi\fi\fi
  \ifnum\lams@shaft=\m@ne
  \else
   \loop
    \ifdim\lams@goal>\lams@ht
    \ifE@\else\hskip-\lams@wd\fi
    \lams@next
    \next@\lams@shift\copy\lams@shaftbox
    \ifE@\else\hskip-\lams@wd\fi
    \advance\lams@shift\lams@ht\advance\lams@goal-\lams@ht
    \repeat
   \ifdim\lams@goal>\z@
    \dimen@\lams@ht\advance\dimen@-\lams@goal
    \divide\dimen@\lams@tani\multiply\dimen@\lams@tanii
    \ifE@\hskip-\dimen@\else\hskip-\lams@wd\hskip\dimen@\fi
    \lams@adj\lams@shift\advance\lams@adj-\lams@ht
    \advance\lams@adj\lams@goal
    \lams@next
    \next@\lams@adj\copy\lams@shaftbox
    \ifE@\else\hskip-\lams@wd\fi
   \else
    \lams@adj\lams@shift\advance\lams@adj-\lams@ht
   \fi
  \fi
  \ifnum\lams@shaft=\m@ne
  \else
   \ifnum\lams@shaft=\thr@@
   \else
    \ifnum\lams@target=\m@ne
    \else
     \setbox\lams@ZERO
      \hbox{\ifnum\lams@ang=117 
       \lamsfont@v\else\arrowfont@\fi\char\lams@T}%
     \ifnum\lams@target=\thr@@
      \advance\lams@adj\lams@ht
      \ifE@\else\ifN@\hskip-\lams@wd\else\hskip-\wd\lams@ZERO\fi\fi
     \else
      \ifnum\lams@target=12
       \advance\lams@adj\lams@ht
       \ifE@\else\ifN@\hskip-\lams@wd\else\hskip-\wd\lams@ZERO\fi\fi
      \else
       \ifE@\hskip-\wd\lams@ZERO\fi
     \fi\fi
     \lams@next
     \next@\lams@adj\copy\lams@ZERO
     \ifnum\lams@target=13
      \hskip-\wd\lams@ZERO
      \lams@cos{\thr@@\p@}%
      \ifE@\hskip-\dimen@\else\hskip\dimen@\fi
      \advance\lams@adj-\dimen@ii
      \lams@next
      \next@\lams@adj\box\lams@ZERO
     \fi
  \fi\fi\fi}}%
}


%%%%%%%%%%%%%%%%%%%% \lams@harrow
%
% Performs actual drawing of horizontal arrows.
%
% EXTERNAL VARS USED
%
% \lams@shaft \lams@source \lams@target
%
% \ifE@ (computed by \lams@arrow)
% \lams@center \lams@firstx \lams@lastx (ibid)
% \lamsfont@i \lamsfont@ii (lams fonts)
%
% \lams@axis (to correct centering of head/tail symbol chars)
%
% INTERNAL VARS USED
%
% \dimen@ \dimen@ii
% \leads@ \lams@ZERO

\newdimen\lams@axis \lams@axis90\p@\divide\lams@axis36

\def\lams@harrow{\dimen@\lams@lastx\advance\dimen@-\lams@firstx
 \ifE@\let\next@\rlap\else\multiply\dimen@\m@ne\let\next@\llap\fi
 \next@{\ifE@\hskip\lams@center\hskip\lams@firstx\fi
  \smash{\raise-\lams@axis\hbox to\dimen@
   {\lamsfont@ii
    \ifnum\lams@shaft=\m@ne\else\ifnum\lams@shaft=\thr@@\else
     \ifE@
      \ifnum\lams@source=\m@ne
      \else
       \ifcase\lams@source\or\or\char118 \or\char117 \or
       \or\or\char119 \or\char120 \or\char121 \or\char122 \or
       \or\or\lamsfont@i\char125 \or
       \char117 \hskip\thr@@\p@\char117 \hskip-\thr@@\p@\fi
      \fi
     \else
      \ifnum\lams@target=\m@ne
      \else
       \ifcase\lams@target\char117 \or\or\char117 \or\char118 \or
       \char119 \or\char120 \or\or\or\or\or\char121 \or
       \char122 \or\lamsfont@i\char125
       \or\char117 \hskip\thr@@\p@\char117 \hskip-\thr@@\p@\fi
      \fi
     \fi
    \fi\fi
    \dimen@\lams@axis\advance\dimen@.2\p@
    \dimen@ii\lams@axis\advance\dimen@ii-.2\p@
    \ifnum\lams@shaft=\m@ne
     \let\leads@\null
    \else
     \ifcase\lams@shaft
      \def\leads@{\hrule\@height\dimen@\@depth-\dimen@ii}\or
      \def\leads@{\hrule\@height\dimen@\@depth-\dimen@ii}\or
      \def\leads@{\hbox to\ten@\p@{%
       \leaders\hrule\@height\dimen@\@depth-\dimen@ii\hfil
       \hfil
      \leaders\hrule\@height\dimen@\@depth-\dimen@ii
       \hskip\z@ plus2fil\relax
       \hfil
       \leaders\hrule\@height\dimen@\@depth-\dimen@ii\hfil}}\or
     \def\leads@{\hbox{\hbox to\ten@\p@{%
       \dimen@\lams@axis\advance\dimen@1.2\p@
       \dimen@ii\dimen@\advance\dimen@ii-.4\p@
       \leaders\hrule\@height\dimen@\@depth-\dimen@ii\hfil}%
       \kern-\ten@\p@
       \hbox to\ten@\p@{\dimen@\lams@axis\advance\dimen@-1.2\p@
       \dimen@ii\dimen@\advance\dimen@ii-.4\p@
       \leaders\hrule\@height\dimen@\@depth-\dimen@ii\hfil}}}\fi
    \fi
    \cleaders\leads@\hfil
    \ifnum\lams@shaft=\m@ne\else\ifnum\lams@shaft=\thr@@\else
     \lamsfont@i
     \ifE@
      \ifnum\lams@target=\m@ne
      \else
       \ifcase\lams@target\char119 \or\or\char119 \or\char120 \or
       \char121 \or\char122 \or \or\or\or\or\char123 \or
       \char124 \or\char125 \or
       \char119 \hskip-\thr@@\p@\char119 \hskip\thr@@\p@\fi
      \fi
     \else
      \ifcase\lams@source\or\or\char120 \or\char119 \or
       \or\or\char121 \or\char122 \or\char123 \or
       \char124 \or\or\or\char125 \or
       \char119 \hskip-\thr@@\p@\char119 \hskip\thr@@\p@\fi
     \fi
    \fi\fi}}%
  \ifE@\else\hskip-\lams@firstx\hskip-\lams@center\fi}%
}
  

%%%%%%%%%%%%%%%%%%%% \lams@varrow
%
% Performs actual drawing of vertical arrows.
%
% EXTERNAL VARS USED
%
% \lams@shaft \lams@source \lams@target
%
% \ifN@ (computed by \lams@arrow)
% \lams@center \lams@firsty \lams@lasty (ibid)
%
% \lamsfont@iii \lamsfont@iv (lams fonts)
%
% INTERNAL VARS USED
%
% \dimen@ \dimen@ii
% \leads@ \lams@ZERO

\def\lams@varrow{\dimen@\lams@lasty\advance\dimen@-\lams@firsty
 \ifN@\else\multiply\dimen@\m@ne\fi
 \setbox\lams@ZERO\vbox to\dimen@
  {\ifnum\lams@shaft=\m@ne\else\ifnum\lams@shaft=\thr@@\else
    \hbox{\lamsfont@iii
     \ifN@
      \ifnum\lams@target=\m@ne
      \else
       \ifcase\lams@target\char117 \or\or\char117 \or
       \char118 \or\char119 \or\char120 \or\or\or\or
       \or\char121 \or\char122 \or\char123 \or
       \vbox{\hbox{\char117}\nointerlineskip\vskip\thr@@\p@
       \hbox{\char117}\vskip-\thr@@\p@}\fi
      \fi
     \else
      \ifcase\lams@source\or\or\char118 \or\char117 \or\or
      \or\char119 \or\char120 \or\char121 \or\char122 \or
      \or\or\char123 \or
      \vbox{\hbox{\char117}\nointerlineskip\vskip\thr@@\p@
      \hbox{\char117}\vskip-\thr@@\p@}\fi
     \fi}%
    \nointerlineskip
   \fi\fi
   \ifnum\lams@shaft=\m@ne
    \let\leads@\null
   \else
    \ifcase\lams@shaft\let\leads@\vrule\or\let\leads@\vrule\or
    \def\leads@{\vbox to\ten@\p@{%
     \hrule\@height1.67\p@\@depth\z@\@width.4\p@
     \vfil
     \hrule\@height3.33\p@\@depth\z@\@width.4\p@
     \vfil
     \hrule\@height1.67\p@\@depth\z@\@width.4\p@}}\or
    \def\leads@{\hbox{\vrule\@height\p@\hskip\tw@\p@\vrule}}\fi
   \fi
  \cleaders\leads@\vfill\nointerlineskip
   \ifnum\lams@shaft=\m@ne\else\ifnum\lams@shaft=\thr@@\else
    \hbox{\lamsfont@iv
     \ifN@
      \ifcase\lams@source\or\or\char118 \or\char117 \or
      \or\or\char119 \or\char120 \or\char121 \or\char122 \or
      \or\or\lamsfont@iii\char123 \or
      \vbox{\hbox{\char117}\nointerlineskip\vskip-\thr@@\p@
      \hbox{\char117}\vskip\thr@@\p@}\fi
     \else
      \ifnum\lams@target=\m@ne
      \else
       \ifcase\lams@target\char117 \or\or\char117 \or\char118 \or
       \char119 \or\char120 \or\or\or\or\or\char121 \or
       \char122 \or\lamsfont@iii\char123 \or
       \vbox{\hbox{\char117}\nointerlineskip\vskip-\thr@@\p@
       \hbox{\char117}\vskip\thr@@\p@}\fi
      \fi
     \fi}%
   \fi\fi}%
 \ifN@
  \dimen@ii\lams@firsty
 \else
  \dimen@ii-\lams@firsty\advance\dimen@ii\ht\lams@ZERO
  \multiply\dimen@ii\m@ne
 \fi
 \rlap{\smash{\hskip\lams@center\raise\dimen@ii\box\lams@ZERO}}%
}


