% --------------------------------------%--------------------------------------
% ---------------------------- Identification part ----------------------------
% --------------------------------------%--------------------------------------

\RequirePackage{rcs}
\RequirePackage{ifthen}

\RCS$Date: 1997/04/23 14:57:45 $
\RCS$RCSfile: aamar.sty,v $
\RCS$Revision: 1.0 $
\RCS$State: OK $
\RCS$Author: anders $

\def\aabasenamex#1.#2,#3{#1}
\def\aafiletypex#1.#2,#3{#2}
\def\aabasename{\expandafter\aabasenamex\RCSRCSfile}
\ifthenelse{\equal{\@clsextension}{\expandafter\aafiletypex\RCSRCSfile}}{%
  \def\aafiletype{Class}}{%
  \def\aafiletype{Package}}
\ifthenelse{\equal{OK}{\RCSState}}{%
  \def\aastate{ }}{%
  \def\aastate{ (\RCSState) }}
\typeout{\aafiletype: `\aabasename' v\RCSRevision\aastate
  <\RCSRawDate> (\RCSAuthor)}

\NeedsTeXFormat{LaTeX2e}
\ifthenelse{\equal{\aafiletype}{Class}}{%
  \ProvidesClass{\aabasename}[\RCSRawDate]}{%
  \ProvidesPackage{\aabasename}[\RCSRawDate]}


% --------------------------------------%--------------------------------------
% -------------------------------- Description --------------------------------
% --------------------------------------%--------------------------------------

% The xymatrix arrow (\mar) is an \ar command in a xymatrix.  You must
% specify a direction for each arrow.  You can also modify the behavior of
% the arrow by specifying an optional first argument which will be added to
% the \ar command.   An optional label can also be added.  We can use \mar
% to typeset (at least) 2 types of arrows in a xymatrix.
%
% 1. An arrow from on object to another:
%
% You give the direction from the current object to the other on (u = up, r
% = right, d = down, l = left, ur/ru = up and to the right, ul/lu = up and
% to the left, ...
% 
% An arrow with the label f from this object to the one at the left (l):
%
%         \mar{l}^{f}
%
% The same arrow dashed:
%
%         \mar[@{-->}]{l}^{f}
%
% An arrow without a label from this object to the one down and at the
% right (dr):
%
%         \mar{dr}
%
% 2. An arrow back to the same object:
%
% You put a * mark before the direction and gives two directions, where the
% arrow begin and end.  You can give 8 directions (u, ur/ru, r, dr/rd, d,
% dl/ld, l, ul/lu).
%
% An clock-wise arrow with the label 1_A and with the top turning point up
% and at the left (ul):
%
%         \mar*{u,l}^{1_A}
%
% Some (2) examples:
%
%         \[
%         \begin{xy}
%           \xymatrix{
%             A
%             \mar*{ur,ul}_{1_A}
%             \mar*{ul,dl}_{f}
%             \mar[@/^2.5ex/]{r}^{g}
%             \mar{r}|{h} 
%             \mar[@/_2ex/]{dr}_{m}
%             & B
%             \mar*{dr,ur}_{1_B}
%             \mar[@/^2.5ex/]{l}^{k}
%             \mar[@{-->}]{d}^{l} \\
%             & C
%             \mar*{dl,dr}^{1_C}
%             }
%         \end{xy}
%         \]
%
%         \[
%         \begin{xy}
%           \xymatrix{
%             A \mar*{ul,ur}^{i} \mar*{ur,dr}^{j} \mar*{dr,dl}^{k} \mar*{dl,ul}^{l}
%             & & B \mar*{r,u}_{a} \mar*{d,r}_{b} \mar*{l,d}_{c} \mar*{u,l}_{d}
%             }
%         \end{xy}
%         \]
%
% Thanks to Kristoffer H. Rose for hints and tips.


% --------------------------------------%--------------------------------------
% -------------------------- Declaration of options ---------------------------
% --------------------------------------%--------------------------------------

\DeclareOption{ps}{%
  \PassOptionsToPackage{dvips}{xy}
  \AtEndOfPackage{\UsePSspecials{dvips}}}
\DeclareOption{dvips}{%
  \PassOptionsToPackage{dvips}{xy}
  \AtEndOfPackage{\UsePSspecials{dvips}}}


% --------------------------------------%--------------------------------------
% --------------------------- Execution of options ----------------------------
% --------------------------------------%--------------------------------------

\ProcessOptions


% --------------------------------------%--------------------------------------
% ------------------------------ Package loading ------------------------------
% --------------------------------------%--------------------------------------

\RequirePackage[arrow,matrix,curve]{xy}[1995/07/07]


% --------------------------------------%--------------------------------------
% --------------------------------- Main code ---------------------------------
% --------------------------------------%--------------------------------------

% Arrows for xymatrix
% \mar has 3 arguments, where the first and third is optional:
%   #1: commands to \ar (optional @{-->} or @/^1.5pt/)
%   #2: the direction of the arrow (u,r,d,l,ur,dr,dl,ul,...)
%   #3: the label (optional and starts with ^, _ or |)
% You can also give a type mark before the first argument (* or none).

% 2 types of arrows:
%   *:    back to the same object
%   none: from one object to another
\newcommand{\mar}[1][]{%
  \@ifnextchar*{\@marso[#1]}{%
    \@mar[#1]}}
\def\@mar[#1]#2{\ar#1[#2]}
\def\@marso[#1]*#2{\marso[#1]{#2}}

% in XY-pic, @ has another meaning than just a letter.
\makeatother

% And arrow starting and ending in the same object. #2 is a pair of
% directions like {u,l} or {ur,dr}.
\def\marso[#1]#2{\ar@(#2)#1[]}

% @ letter again
\makeatletter

% LocalWords:  aamar AA ps dvips xy ifthen ifnextchar marclw marcow 
% LocalWords:  dr ld dl lu ul ru ur
