% pb-lams.sty: LAMS-TeX font enhancements for pb-diagram.sty
% Author: Paul Burchard <burchard@math.utah.edu>
% Version Number: 4.1
% Version Date: 24 Jan 1997
%
% This style file should be loaded *AFTER* pb-diagram.sty and
% lamsarrow.sty.
%
% This code adds to the "diagram" environment the use of
% fancy arrow heads and tails, as well as additional arrow
% directions.  Most of the options defined here can be
% combined arbitrarily.
%

\@ifundefined{diagram}{%
   \@latexerr{The pb-lams style option requires pb-diagram}%
   {You must include the pb-diagram package prior to pb-lams.}}{}
\@ifundefined{lamsvector}{%
   \@latexerr{The pb-lams style option requires lamsarrow}%
   {You must include the lamsarrow package prior to pb-lams.}}{}

\newif\ifdg@LATEXGEOM \dg@LATEXGEOMfalse

\@namedef{dgo@}{%
   \let\dg@VECTOR=\lamsvector
   \lamsshaft{?}\lamssource{?}\lamstarget{?}%
   \dg@LBLPOS=\dgARROWPARTS \divide\dg@LBLPOS\tw@\relax}%
\@namedef{dgo@..}{\lamsshaft{.}}%
\@namedef{dgo@<>}{\lamssource{^}\lamstarget{^}}%
\@namedef{dgo@=}{\lamsshaft{=}}%
\@namedef{dgo@-}{\lamstarget{0}}%
\@namedef{dgo@'}{\lamstarget{'}}%
\@namedef{dgo@`}{\lamstarget{`}}%
\@namedef{dgo@A}{\lamstarget{A}}%
\@namedef{dgo@V}{\lamssource{V}}%
\@namedef{dgo@J}{\lamssource{J}}%
\@namedef{dgo@L}{\lamssource{L}}%
\@namedef{dgo@S}{\lamssource{S}}%
%
% approximate aspect ratio by half-integer betw 1/2 and 3
% (or betw 1/2 and 2 if 3:1 arrow detected)
%
\def\dggeometry{
   \dg@ZTEMP=\dg@XGRID \multiply\dg@ZTEMP\tw@
   \ifnum\dg@YGRID=\z@ \dg@ZTEMP=\tw@
   \else \divide\dg@ZTEMP\dg@YGRID \fi
   % font limit cutoffs
   \ifnum\dg@ZTEMP>6\relax \dg@ZTEMP=6\relax \fi
   \ifdg@LATEXGEOM\ifnum\dg@ZTEMP>\f@ur \dg@ZTEMP=\f@ur \fi\fi
   \ifnum\dg@ZTEMP<\@ne \dg@ZTEMP=\@ne \fi
   \unitlength=1sp\relax
   \ifnum\dg@ZTEMP<\tw@
      % round aspect ratio up toward 2:2, widen rect
      \advance\dg@ZTEMP\@ne
      \multiply\unitlength\dg@YGRID
      \dg@XGRID=\dg@ZTEMP \dg@YGRID=\tw@
      \dg@rmcommondiv\tw@\dg@XGRID\dg@YGRID
      \divide\unitlength\dg@YGRID
   \else
      % round aspect ratio down toward 2:2, tallen rect
      \multiply\unitlength\dg@XGRID
      \dg@XGRID=\dg@ZTEMP \dg@YGRID=\tw@
      \dg@rmcommondiv\tw@\dg@XGRID\dg@YGRID
      \divide\unitlength\dg@XGRID
   \fi
   \divide\unitlength\@m\relax
   \dg@LATEXGEOMfalse}
%
% Bugwards-compatibility mode for versions 3.6 and earlier.
% Enable it with \let\dggeometry=\dgoldgeometry
%
\def\dgoldgeometry{
   \dg@ZTEMP=\dg@XGRID \multiply\dg@ZTEMP\tw@
   \ifnum\dg@YGRID=\z@ \dg@ZTEMP=\tw@
   \else \divide\dg@ZTEMP\dg@YGRID \fi
   % font limit cutoffs
   \ifnum\dg@ZTEMP>6\relax \dg@ZTEMP=6\relax \fi
   \ifdg@LATEXGEOM\ifnum\dg@ZTEMP>\f@ur \dg@ZTEMP=\f@ur \fi\fi
   \ifnum\dg@ZTEMP<\@ne \dg@ZTEMP=\@ne \fi
   % The following calculation is garbled!
   \unitlength=2sp\relax
   \ifnum\dg@ZTEMP<\tw@
      % round aspect ratio up toward 2:2, widen rect
      \advance\dg@ZTEMP\@ne
      \multiply\unitlength\dg@YGRID \divide\unitlength\tw@
   \else
      % round aspect ratio down toward 2:2, tallen rect
      \multiply\unitlength\dg@XGRID \divide\unitlength\dg@ZTEMP
   \fi
   \dg@XGRID=\dg@ZTEMP \dg@YGRID=\tw@
   \dg@rmcommondiv\tw@\dg@XGRID\dg@YGRID
   \divide\unitlength\dg@YGRID \divide\unitlength\@m
   \dg@LATEXGEOMfalse}
%
% new directions
\def\dgt@nee{\dg@DX=\tw@ \dg@DY=\@ne \dg@SIZE=\tw@}%
\def\dgt@see{\dg@DX=\tw@ \dg@DY=\m@ne \dg@SIZE=\tw@}%
\def\dgt@nww{\dg@DX=-\tw@ \dg@DY=\@ne \dg@SIZE=\tw@}%
\def\dgt@sww{\dg@DX=-\tw@ \dg@DY=\m@ne \dg@SIZE=\tw@}%
\def\dgt@nnne{\dg@DX=\@ne \dg@DY=\thr@@ \dg@SIZE=\@ne}%
\def\dgt@nnnw{\dg@DX=\m@ne \dg@DY=\thr@@ \dg@SIZE=\@ne}%
\def\dgt@sssw{\dg@DX=\m@ne \dg@DY=-\thr@@ \dg@SIZE=\@ne}%
\def\dgt@ssse{\dg@DX=\@ne \dg@DY=-\thr@@ \dg@SIZE=\@ne}%
\def\dgt@nnnee{\dg@DX=\tw@ \dg@DY=\thr@@ \dg@SIZE=\tw@}%
\def\dgt@nnnww{\dg@DX=-\tw@ \dg@DY=\thr@@ \dg@SIZE=\tw@}%
\def\dgt@sssww{\dg@DX=-\tw@ \dg@DY=-\thr@@ \dg@SIZE=\tw@}%
\def\dgt@sssee{\dg@DX=\tw@ \dg@DY=-\thr@@ \dg@SIZE=\tw@}%
%
% these are only drawn approx correct in some aspect ratios:
\def\dgt@nneee{\dg@DX=\thr@@ \dg@DY=\tw@ \dg@SIZE=\thr@@}%
\def\dgt@nnwww{\dg@DX=-\thr@@ \dg@DY=\tw@ \dg@SIZE=\thr@@}%
\def\dgt@sswww{\dg@DX=-\thr@@ \dg@DY=-\tw@ \dg@SIZE=\thr@@}%
\def\dgt@sseee{\dg@DX=\thr@@ \dg@DY=-\tw@ \dg@SIZE=\thr@@}%
%
% these only work with LaTeX-compatible aspect ratios:
% must set this globally to see it later!!!
\def\dgt@neee{\dg@DX=\thr@@ \dg@DY=\@ne \dg@SIZE=\thr@@
   \global\dg@LATEXGEOMtrue}%
\def\dgt@nwww{\dg@DX=-\thr@@ \dg@DY=\@ne \dg@SIZE=\thr@@
   \global\dg@LATEXGEOMtrue}%
\def\dgt@swww{\dg@DX=-\thr@@ \dg@DY=\m@ne \dg@SIZE=\thr@@
   \global\dg@LATEXGEOMtrue}%
\def\dgt@seee{\dg@DX=\thr@@ \dg@DY=\m@ne \dg@SIZE=\thr@@
   \global\dg@LATEXGEOMtrue}%

