% \iffalse meta-comment
%
% Copyright 2006--2022 Jérôme Lelong <jerome.lelong@gmail.com>
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later.
% 
% 
% \fi
% \iffalse
%<*driver>
\ProvidesFile{amsaddr.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{amsaddr}
%<*class>
    [2022/09/10 v1.2 .dtx amsaddr file]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{a4}
\DisableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{amsaddr.dtx}
  \PrintChanges
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{amsaddr.dtx}
% \CheckSum{328}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.0}{2004/11/05}{Initial version}
% \changes{v1.1}{2013/04/02}{Fix space alignment}
% \changes{v1.2}{2022/09/10}{Fix error with \\dedicatory}
%
% \GetFileInfo{amsaddr.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \date{\today}
% \title{The \textsf{amsaddr} class\thanks{This document
%   corresponds to \textsf{amsaddr}~\fileversion, dated \filedate.}}
% \author{J\'er\^ome Lelong \\ \texttt{jerome.lelong@gmail.com}}
%
% \maketitle
%
% \begin{abstract}
%   This package is intended to be used with the \textsf{amsart} documentclass only. It
%   lets you move the authors' affiliations either just below the
%   authors' names on the front page or as footnotes on the first page. The email
%   addresses are always listed as a footnote on the front page.
% \end{abstract}
%
%
% \tableofcontents
%
% \section{License}
%
% This package is copyright \textcopyright\ 2006-2022 by:
%
% \begin{quote}
%   J\'er\^ome Lelong,
%   Univ. Grenoble Alples, Grenoble Institute of Technology,
%   Grenoble, France\\
%   E-Mail: \texttt{jerome.lelong@gmail.com}
% \end{quote}
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License, distributed from CTAN
% archives available from \texttt{http://www.latex-project.org/lppl.txt}; either
% version 1.3c of the License, or (at your option) any later version. 
%
%
% \section{Usage}
%
%
% To use this package, you need to include the directive |\usepackage{amsaddr}| in your
% |.tex| file. Alternatively, you may also use it with the |foot| option
% |\usepackage[foot]{amsaddr}|. When using the |foot| option, the adresses are put as
% footnotes on the first page of the document.
%
% A typical usage looks like the following
%
% \begin{verbatim}
% \author{author one and author two}
% \address{common address of authors one and two}
% 
% \author{author three}
% \address{author three address}
% 
% \email{list of emails}
% \end{verbatim}
% 
% If |amsaddr| is used without the |foot| option, the addresses declared with the
% |\address| command are printed just below the authors'names declared with the
% preceeding |\author| command. The emails appear as a footnote like this
% \\
% 
% {\it E-mail addresses:} {\texttt{email one}, \texttt{email two}, and so on}
% \\
%
% If the option |foot| was passed to the package, you may consider numbering
% authors' names so that you can use numbered footnotes for the affiliations.
% 
% \begin{verbatim}
% \author{author one$^1$ and author two$^1$}
% \address{$^1$common address of authors one and two}
% 
% \author{author three$^2$}
% \address{$^2$author three address}
% 
% \email{list of emails}
% \end{verbatim}
%
% As in standard |amsart| documents, an option can be passed to the |\author| command
% to specify the replacement for the author's name on the running headers.
%
%\begin{center}
%  \begin{verbatim}
%\author[header name of the author]{author name}
%  \end{verbatim}
%\end{center}
%
%  
% \StopEventually{}
%
% \section{Implementation}
%
%    \begin{macrocode}
  \def\filename{amsaddr}
  \def\fileversion{v1.0}
  \def\filedate{2006/12/12}
  \ifx\protected@edef\@undefined
     \let\protected@edef\edef
  \fi
%    \end{macrocode}
%
% The |foot| option enables to move the affiliation related material to the bottom of
% the fisrt page as footnotes.
%
%    \begin{macrocode}
\newif\if@footaddr
\DeclareOption{foot}{\@footaddrtrue}
\ProcessOptions\relax
%    \end{macrocode}
%
%
% \begin{macro}{\author}
%
% The |\author| macro can be used the same way as in other |amsart| documents. The
% variable |g@author| is used to count the total number of authors.
%
%    \begin{macrocode}
\newcounter{g@author}
\setcounter{g@author}{0}
\renewcommand{\author}[2][]{%
  \stepcounter{g@author}
  \ifx\@empty\authors
    \gdef\authors{#2}%
  \else
    \g@addto@macro\authors{\and#2}%
  \fi
  \g@addto@macro\addresses{\author{#2}}%
  \@ifnotempty{#1}{%
    \ifx\@empty\shortauthors
      \gdef\shortauthors{#1}%
    \else
      \g@addto@macro\shortauthors{\and#1}%
    \fi
  }%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\email}
% The |\email| command is used to specify the different authors. The email addresses
% can be specified in a unique command or using separate invocations of the command.
%    \begin{macrocode}
\let\emails\@empty
\renewcommand{\email}[2][]{
  \ifx\@empty\emails
    \gdef\emails{\mbox{#2}}
  \else
    \g@addto@macro\emails{,\space\mbox{#2}}
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% Process |\author| and |\address| macros 
%
%    \begin{macrocode}
\def\@set@authors@addresses{\par
  \skip@30\p@ 
  \centering
  \begingroup
  \def\author##1{\par\vskip\skip@\MakeUppercase{##1}}%
  \def\\{\protect\linebreak}%
  \centering
  \def\address##1##2{\par\addvspace\bigskipamount%
    {\itshape\ignorespaces##2}%
  }%
  \def\email##1##2{%
    \@ifnotempty{##2}{, \ignorespaces{\ttfamily##2}}}%
  \def\curraddr##1##2{}%
  \def\urladdr##1##2{}%
  \addresses
  \endgroup
  \par
}
%    \end{macrocode}
%
% \begin{macro}{\@setfoot@addresses}
% The |\@setfoot@addresses| macro is used to print the addresses as footnotes. This
% macro is called when the |foot| option is passed to the package.
%    \begin{macrocode}  
\def\@setfoot@addresses{
  \def\author##1{}%
  \def\\{\unskip, \ignorespaces}%
  \newif\if@firstaddr
  \@firstaddrtrue
  \def\address##1##2{%
    \if@firstaddr\@firstaddrfalse\else\par\fi
    \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    {\scshape\ignorespaces##2}%
  }%
  \def\email##1##2{}%
  \def\curraddr##1##2{}%
  \def\urladdr##1##2{}%
  \addresses
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@setaddresses}
% The |\@setaddresses| macro is used to process the addresses when they are to appear
% just below the authors' names on the front page.
%    \begin{macrocode}  
\def\@setaddresses{\par
  \nobreak \begingroup
  \def\author##1{\nobreak\addvspace\bigskipamount}%
  \def\\{\unskip, \ignorespaces}%
  \interlinepenalty\@M
  \def\address##1##2{}%
  \def\email##1##2{}%
  \def\curraddr##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent{\itshape Current address}%
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      ##2\par}\endgroup}%
  \def\urladdr##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent{\itshape URL}%
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \addresses
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@setemails}
% The |\@setemails| macro is called by the |\maketitle| command to print the email
% addresses.
%    \begin{macrocode}
\def\@setemails{%
  \ifnum\theg@author > 1
    \mbox{{\itshape E-mail addresses}:\space}{\ttfamily\emails}.
  \else
    \mbox{{\itshape E-mail address}:\space}{\ttfamily\emails}.
  \fi%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@maketitle}
% The |\@maketitle| macro is used to replace the standard |\makefile| command. Before
% issuing this command, no authors, affiliations, nor emails are printed.
%    \begin{macrocode}  
\def\@maketitle{%
  \normalfont\normalsize
  \let\@makefnmark\relax  \let\@thefnmark\relax
  \if@footaddr\@footnotetext{\@setfoot@addresses}\fi
  \ifx\@empty\emails\else \@footnotetext{\@setemails}\fi
  \ifx\@empty\@date\else \@footnotetext{\@setdate}\fi
  \ifx\@empty\@subjclass\else \@footnotetext{\@setsubjclass}\fi
  \ifx\@empty\@keywords\else \@footnotetext{\@setkeywords}\fi
  \ifx\@empty\thankses\else \@footnotetext{%
    \def\par{\let\par\@par}\@setthanks}\fi
  \@mkboth{\@nx\shortauthors}{\@nx\shorttitle}%
  \global\topskip42\p@\relax % 5.5pc   "   "   "     "     "
  \@settitle
  \if@footaddr\ifx\@empty\authors \else \@setauthors \fi
  \else%
     \ifx\@empty\authors \else \@set@authors@addresses \fi
  \fi
  \ifx\@empty\@dedicatory
  \else
    \baselineskip18\p@
    \vtop{\centering{\footnotesize\itshape\@dedicatory\@@par}%
      \global\dimen@i\prevdepth}\prevdepth\dimen@i
  \fi
  \@setabstract
  \normalsize
  \if@titlepage
    \newpage
  \else
    \dimen@34\p@ \advance\dimen@-\baselineskip
    \vskip\dimen@\relax
  \fi
  \let\addresses\relax
  \let\@setfoot@addresses\relax
} % end \@maketitle
%    \end{macrocode}
% \end{macro}
%
% In |amsart| documents, affiliations are normally printed by the |\enddoc@text|
% command . To avoid a double printing of the considered material, the |\enddoc@text|
% macro has to be redefined.
%
%    \begin{macrocode}
\def\enddoc@text{
  \ifx\@empty\addresses\else \@setaddresses\fi
}
%    \end{macrocode}
% \Finale
\endinput
