% ACOMPAT.TEX  VERSION 2.0
% COPYRIGHT (C) 1991 BY THE TEXPLORATORS CORPORATION
% ALL RIGHTS RESERVED

% THIS FILE SHOULD NOT BE CHANGED IN ANY WAY. 

%% This file allows certain modifications that might be desired
%% if an old AmS-TeX file has to be run through LamS-TeX.

%% First of all
%%
%%      \manualtags
%%
%% causes \tag to revert to its AmS-TeX usage: instead of
%% simply typing
%%
%%      $$ x=y \tag $$
%%
%% and expecting LamS-TeX to supply the \tag number automatically,
%% one would type an explicit \tag like
%%
%%      $$ x=y \tag 3 $$
%%
%% which would give the tag (3) [the formatting of the tag 
%% number can still be changed with \newstyle\tag].
%%
%% It is possible to specify \manualtags within a group if
%% only part of a paper uses the AmS-TeX conventions.

%% Similarly, the command
%%
%%     \amstexCDs
%%
%% makes \CD act exactly as in AmS-TeX, with no &'s, and 
%% with @>>> and @<<< for horizontal arrows, @ AAA and @ VVV for 
%% vertical arrows, @. for an `empty arrow', @= for a horizontal
%% long equal sign, and @| or @\vert for a vertical long equal sign.
%% Moreover, @))) and @((( can be used for @>>> and @<<< --- an 
%% addition made in version 2.0 of AmS-TeX.
%%
%% \amstexCDs can also be used within a group, in case some \CD's
%% are in the AmS-TeX format, while others are in LamS-TeX format.


%% By the way, once this file has been \input, @>>> and @<<< 
%% can even be used in math mode, outside of commutative diagrams,
%% just as in AmS-TeX, giving the same result as LamS-TeX's 
%% \East and \West. [But you can't use the alternatives @((( and @)))
%% this way.]


%% Although \amstexCDs allows \CD's from an old AmS-TeX file to
%% be used with LamS-TeX, note that these rectangular \CD's will 
%% not look the same as those produced by LamS-TeX.  However,
%% there is also \OCD...\endOCD  (`old \CD'), which gives exactly the
%% same diagrams as ordinary LamS-TeX diagrams, but which requires
%% only rather modest amounts of editing.  For example, instead of
%%
%%      \amstexCDs
%%      $$
%%      \CD
%%      G @)\alpha)\beta) H @= K @>\alpha>\beta > L\\
%%      @VfVgV @AfAgA  @|  @. \\
%%      G' @(\alpha(\beta( H' @. K' @<\alpha<\beta< L'
%%      \endCD
%%      $$
%%
%% you can type
%%
%%      $$
%%      \OCD
%%      G @VfVgV @)\alpha)\beta) H @= K @>\alpha>\beta > L\\
%%      %
%%      G' @(\alpha(\beta( H' @AfAgA @. K' @| @<\alpha<\beta< L'
%%      \endOCD
%%      $$
%%
%% and get a commutative diagram that looks exactly like those normally
%% produced by LamS-TeX.
%%
%% The changes that have to be made are covered by the following rules:
%% 
%% (1) The `rows' with vertical arrows are eliminated.
%% (2) Vertical arrows should instead be placed after the vertex at 
%%     which they start. In other words, @VVV arrows should be placed
%%     after the vertex above, and @AAA arrows should be placed after 
%%     the vertex below; a vertical long equal sign, @| or @\vert, is
%%     to be treated like @AAA (i.e., it is thought of as pointing
%%     upwards).
%% (3) These vertical arrows always go BEFORE any horizontal arrow
%%     at the vertex.
%% (4) Horizontal `empty arrows' are retained, but vertical ones
%%     are eliminated.
%%
%% Note that \OCD...\endOCD will give \tsize labels, the default for
%% commutative diagrams in LamS-TeX, but if \amstexCD's is specified,
%% then \CD...\endCD gives \ssize labels, the default in AmS-TeX. 
%% If you want \OCD...\endOCD to give \ssize labels, type 
%% \ssizeCDlabels\OCD ... \endOCD. 


%% In LamS-TeX, \endCD is actually part of the `syntax' for \CD, not
%% an independent control sequence.  So if you tried 
%%
%%    \define\cd{\CD}
%%    \define\endcd{\endCD}
%%
%% then \cd...\endcd would not work.  However, you could
%%
%%    \define\cd#1\endcd{\CD#1\endCD}
%%
%% and then you could use \cd...\endcd instead of \CD...\endCD. 
%% The same holds for \OCD...\endOCD.  So you could, for example,
%%
%%    \define\ocd#1\endocd{\ssizeCDlabels\OCD#1\endOCD}
%%
%% and then use \ocd...\endocd to have \ssizeCDlabels automatically.
%% (You could even
%%
%%    \predefine\OCDoriginal{\OCD}
%%    \redefine\OCD#1\endOCD{\ssizeCDlabels\OCDoriginal#1\endOCD}
%%
%% if you wanted to use \OCD...\endOCD and have \ssizeCDlabels
%% automatically.)


\catcode`\@=11
\let\alloc@\alloc@
\def\manualtags{\def\maketag@@@@##1\maketag@{\hbox{\tag@S{\tag@F
  \ignorespaces##1\unskip}}}}
\let\CD@\CD
\atdef@>#1>#2>{\ampersand@                                               
 \setboxz@h{$\m@th\ssize\;{#1}\;\;$}%                                    
 \setbox\tw@\hbox{$\m@th\ssize\;{#2}\;\;$}%                               
 \setbox4=\hbox{$\m@th#2$}%                                            
 \ifCD@\global\bigaw@\minCDaw@\else\global\bigaw@\minaw@\fi           
 \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
 \ifdim\wd\tw@>\bigaw@\global\bigaw@\wd\tw@\fi                            
 \ifCD@\hskip.5em\fi                                                 
 \ifdim\wd4 >\z@
  \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill}}\limits^{#1}_{#2}}%   
 \else\mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill}}\limits^{#1}}\fi
 \ifCD@\hskip.5em\fi
 \ampersand@}%
\atdef@<#1<#2<{\ampersand@\setboxz@h{$\m@th\ssize\;\;{#1}\;$}%
 \setbox\tw@\hbox{$\m@th\ssize\;\;{#2}\;$}\setbox4=\hbox{$\m@th#2$}%
 \ifCD@\global\bigaw@\minCDaw@\else\global\bigaw@\minaw@\fi
 \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
 \ifdim\wd\tw@>\bigaw@\global\bigaw@\wd\tw@\fi
 \ifCD@\hskip.5em\fi
 \ifdim\wd4 >\z@
  \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill}}\limits^{#1}_{#2}}\else
  \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill}}\limits^{#1}}\fi
 \ifCD@\hskip.5em\fi\ampersand@}
\let\ampersand@\relax
\newdimen\minCDaw@
\minCDaw@2.5pc
\def\minCDarrowwidth#1{\RIfMIfI@\onlydmatherr@\minCDarrowwidth
 \else\minCDaw@#1\relax\fi\else\onlydmatherr@\minCDarrowwidth\fi}
\newdimen\bigaw@
\newif\ifCD@
\def\amstexCDs{%
 \atdef@ A##1A##2A{\llap{$\m@th\vcenter{\hbox
  {$\ssize##1$}}$}\Big\uparrow\rlap{$\m@th\vcenter{\hbox{$\ssize##2$}}$}&&}%
 \atdef@ V##1V##2V{\llap{$\m@th\vcenter{\hbox{$\ssize##1$}}$}%
  \Big\downarrow\rlap{$\m@th\vcenter{\hbox{$\ssize##2$}}$}&&}%
 \atdef@={&\hskip.5em\mathrel
  {\vbox{\hrule width\minCDaw@\vskip3\ex@\hrule width
  \minCDaw@}}\hskip.5em&}%
 \atdef@|{\Big\Vert&&}%
 \atdef@\vert{\Big\Vert&&}%
 \def\pretend##1\haswidth##2{\setboxz@h{$\m@th\scriptstyle{##2}$}\hbox
  to\wdz@{\hfill$\m@th\scriptstyle{##1}$\hfill}}%
 \atdef@.{&&}%
 \atdef@)##1)##2){\ampersand@
  \setboxz@h{$\m@th\ssize\;{##1}\;\;$}%
  \setbox\tw@\hbox{$\m@th\ssize\;{##2}\;\;$}%
  \setbox4=\hbox{$\m@th##2$}%
  \ifCD@
  \global\bigaw@\minCDaw@\else\global\bigaw@\minaw@\fi
  \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
  \ifdim\wd\tw@>\bigaw@\global\bigaw@\wd\tw@\fi
  \ifCD@\hskip.5em\fi
  \ifdim\wd4 >\z@
   \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill}}\limits^{##1}_{##2}}%
  \else\mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill}}\limits^{##1}}\fi
  \ifCD@\hskip.5em\fi
  \ampersand@}%
 \atdef@(##1(##2({\ampersand@\setboxz@h{$\m@th\ssize\;\;{##1}\;$}%
  \setbox\tw@\hbox{$\m@th\ssize\;\;{##2}\;$}\setbox4=\hbox{$\m@th##2$}%
  \ifCD@\global\bigaw@\minCDaw@\else\global\bigaw@\minaw@\fi
  \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
  \ifdim\wd\tw@>\bigaw@\global\bigaw@\wd\tw@\fi
  \ifCD@\hskip.5em\fi
  \ifdim\wd4 >\z@
   \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill}}\limits^{##1}_{##2}}\else
   \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill}}\limits^{##1}}\fi
  \ifCD@\hskip.5em\fi\ampersand@}%
 \def\CD{\bgroup
  \vspace@\relax\iffalse{\fi\let\ampersand@&\iffalse}\fi
  \CD@true\vcenter\bgroup\Let@\tabskip\z@skip\baselineskip20\ex@
  \lineskip3\ex@\lineskiplimit3\ex@\halign\bgroup
  &\hfill$\m@th####$\hfill\crcr}
 \def\endCD{\crcr\egroup\egroup\egroup}%
}
\def\OCD{\bgroup
 \DN@{\let\leftparens@}\expandafter\next@\csname\string @(\endcsname
 \atdef@.{&}%
 \atdef@)##1)##2){\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\leftparens@1,0)&}%
 \atdef@>##1>##2>{\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\leftparens@1,0)&}%
 \atdef@(##1(##2({\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\zero@ h\one@ e\leftparens@1,0)&}%
 \atdef@<##1<##2<{\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\zero@ h\one@ e\leftparens@1,0)&}%
 \atdef@ A##1A##2A{\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\leftparens@0,1)}%
 \atdef@ V##1V##2V{\options@true\begingroup\optioncodes@
  \L@{##1}\l@{##2}\leftparens@0,-1)}%
 \atdef@={\options@true\begingroup\optioncodes@
  \a@=\leftparens@1,0)&}%
 \atdef@|{\options@true\begingroup\optioncodes@
  \a@=\leftparens@0,1)}%
 \atdef@\vert{\options@true\begingroup\optioncodes@
  \a@=\leftparens@0,1)}%
 \def\next@##1\endOCD{\CD@##1\endCD\egroup}%
 \next@}
\def\alloc@#1#2#3#4#5{\global\advance\count1#1by\@ne
 \ch@ck#1#4#2\allocationnumber=\count1#1
 \global#3#5=\allocationnumber
 \wlog{\string#5=\string#2\the\allocationnumber}}
\catcode`\@=\active
