%===========================================================================
% CARMA_MEMO.STY -- Style modifications for CARMA Memorada
%
% This file establishes style customizations for the CARMA memoranda.
% It is used in v5.x via \usepackage{carma_memo}.  In v4.x,
% it is invoked with \documentstyle[carma_memo]{article}.
%
% DO NOT EDIT THIS FILE UNLESS YOU REALLY REALLY KNOW WHAT YOU ARE DOING.
%
% Send question/comments to Marc Pound.
%===========================================================================

\input epsf.sty % required
\typeout{=================================================}
\typeout{Local Document Style `CARMA Memo' <2003-May-29>. }
\typeout{=================================================}

%-----------------------------------------------------------
% Basic page layout
%-----------------------------------------------------------

\marginparwidth  0pt      % Width of marginal notes.
\marginparsep    0pt      % Horizontal space between outer margin and 
                          % marginal note
\parindent       0pt      % paragraph indent
\topmargin       0pt      % Nominal distance from top of page to top of
                          % box containing running head.


%--------------------------------------------------
% Set the number of this memo. Define alma and bima
% memo numbers. Figure out proper footnoting.
%--------------------------------------------------

% Defines the CARMA memo number
\newcommand{\carmamemo}[1]{\def\carmamemonum{#1}}

% Define registers for alma & bima memo numbers.
\newcount\almamemonum
\newcount\bimamemonum
\newcount\nummemo  % generic counter used in if statement below.
\almamemonum=0 % default ALMA Memo number.
\bimamemonum=0 % default BIMA Memo number.
% Commands which set the memo register values
\newcommand{\almamemo}[1]{\almamemonum=#1}
\newcommand{\bimamemo}[1]{\bimamemonum=#1}


%
% Macro to figure out the appropriate footnote if this document is
% also a BIMA or ALMA memo.
%
\def\setfn{
\nummemo=0
\ifnum\almamemonum>0
  \advance\nummemo by 1
% If document is BIMA memo, this footnote is used.
  \def\almafn{This document is also ALMA Memo \# \the\almamemonum}
\else
% else nada
  \def\almafn{\relax}
\fi

\ifnum\bimamemonum>0
  \advance\nummemo by 1
% If document is BIMA memo, this footnote is used.
  \def\bimafn{This document is also BIMA Memo \# \the\bimamemonum}
\else
% else nada
  \def\bimafn{\relax}
\fi
}

%
% If document is both and ALMA and BIMA memo, this footnote is used.
%
\def\bothfn{This document is also ALMA Memo \# \the\almamemonum\ 
	    and BIMA Memo \# \the\bimamemonum}

%
% Macro to set the footnote value.
%
\def\myfn{
  \ifnum\nummemo=0 
	\relax
  \else\ifnum\nummemo=1
% in this case, \almafn or \bimafn will be \relax, but not both
	\footnote{\almafn\bimafn}
  	\else\ifnum\nummemo=2
% otherwise, it's a 3-way memo!
  		\footnote{\bothfn}
  		\fi
  	\fi
  \fi
}

% We don't need the AASTEX revision footnote.
\let\revtex@pageid=\relax
%-----------------------------------------------------------
% Redefine @maketitle from its AASTEX definition. 
% This puts the logo and title/author/abstract in the proper 
% place.  First 8 lines of definition copied from AAXTEX, as
% are a few of the last lines.
%-----------------------------------------------------------
\def\@maketitle{
  \newpage
  \begingroup
   \let\footnote\thanks % for putting footnote on a title
   \let\email\make@authoremail
   \let\affil\make@affil
   \let\altaffilmark\make@altaffilmark
   \let\altaffiltext\make@altaffiltext
   \let\and\make@and
   \setfn % set the footnotes here.
   % Use the minpage construct to give 1/3 the horizontal space 
   % to the CARMA logo and 2/3 to the title/author sequence.
	\begin{minipage}{0.33\linewidth}
	  \epsfxsize=\linewidth
	  \epsfbox{carmalogo.ps}
	\end{minipage}\hfill
	\begin{minipage}{0.67\linewidth}
	   \begin{center}
	   \vspace*{-1em}
	   { \Large
	    CARMA Memorandum Series \#\carmamemonum \myfn 
  	    \@title
	   }
  	    \@author
	    \today
	   \end{center}
	\end{minipage}
    \vspace*{0.5truein}
    \par
    \@abstract
  \endgroup
  \clearpage
}

%--------------------------------------------------
% Change record table macros, Added May 29,2003
%--------------------------------------------------
\newcommand{\ChangeRecordBegin}{%
\maketitle % force the title to be made first, otherwise the table
           % can wind up before the title page
  \begin{table}[h!]
  \begin{center}
   \begin{tabular}{|c|c|c|c|}
   \multicolumn{4}{c}{{\it Change Record}} \\
   \cline{1-4} 
   Revision & Date & Author &
   Sections/Pages Affected \\ \cline{2-4}
   & \multicolumn{3}{|c|}{Remarks} \\ \cline{1-4}
}
\newcommand{\ChangeRecordEnd}{%
   \end{tabular}
  \end{center}
  \end{table}
  \newpage
}
% columns are:
% | revision |date| author| sections/pages affected |
% |          | remarks                              |
\newcommand{\addrevision}[5]{
#1 & #2 & #3 & #4 \\ \cline{2-4}
 & \multicolumn{3}{|c|}{\parbox{6 truein}{\ \\ #5 \\ }} \\ \cline{1-4}

}
%--------------------------------------------------
