%%
%% This is file `PJLauthor.sty',
%% generated with the docstrip utility.

%% Copyright (C) 2021 by Jinwen XU
%% 
%% This is part of the ProjLib Toolkit.
%% 
%% This work 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.
%% 
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesPackage{PJLauthor}
    [2021/07/12 Enhanced author information block]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\ifdefined\subjclass\endinput\fi

%%================================
%% Font and style
%%================================
\def\PJLauthor@font@author{\normalsize\normalfont\scshape}
\def\PJLauthor@font@address{\small\normalfont\itshape}
\def\PJLauthor@font@curraddr{\small\normalfont\itshape}
\def\PJLauthor@font@email{\small\normalfont\ttfamily}

%%================================
%% Lengths
%%================================
\newlength{\PJLauthor@length@innersep}
\setlength{\PJLauthor@length@innersep}{.3\baselineskip}
\newlength{\PJLauthor@length@sep}
\setlength{\PJLauthor@length@sep}{.5\baselineskip}
\newlength{\PJLauthor@length@aftersep}
\setlength{\PJLauthor@length@aftersep}{.3\baselineskip}

%%================================
%% The macros
%%================================
\newif\if@PJLauthor@affilon
\renewcommand*{\author}[1]{%
    \gappto\@author{\phantom{A}\\[-\baselineskip]%
    \vspace{\PJLauthor@length@sep}%
    \PJLauthor@font@author{#1}\\\phantom{}
    \@PJLauthor@affilonfalse}}
\providecommand*{\address}[1]{%
    \gappto\@author{\phantom{A}\\[-\baselineskip]%
        \if@PJLauthor@affilon\else%
            \vspace{\PJLauthor@length@innersep}%
        \fi%
        \@PJLauthor@affilontrue%
        \PJLauthor@font@address{#1}\\\phantom{}}%
}
\providecommand*{\curraddr}[1]{%
    \gappto\@author{\phantom{A}\\[-\baselineskip]%
        \if@PJLauthor@affilon\else%
            \vspace{\PJLauthor@length@innersep}%
        \fi%
        \@PJLauthor@affilontrue%
        \PJLauthor@font@curraddr{#1}\\\phantom{}}%
}
\providecommand*{\email}[1]{%
    \gappto\@author{\phantom{A}\\[-\baselineskip]%
        \if@PJLauthor@affilon\else%
            \vspace{\PJLauthor@length@innersep}%
        \fi%
        \@PJLauthor@affilontrue%
        \PJLauthor@font@email{#1}\\\phantom{}}%
}

%%================================
%% Adjustment
%%================================
\patchcmd{\@maketitle}{\begin{tabular}[t]{c}}{}{}{}
\patchcmd{\@maketitle}{\end{tabular}}{}{}{}
\def\@author{}
\pretocmd{\@maketitle}{%
    \pretocmd{\@author}{\vspace{-\PJLauthor@length@sep}}{}{\FAIL}%
    \apptocmd{\@author}{%
        \vspace{-\baselineskip}%
        \if@PJLauthor@affilon%
            \vspace{\PJLauthor@length@aftersep}%
        \fi%
    }{}{\FAIL}%
}{}{\FAIL}

\endinput
%%
%% End of file `PJLauthor.sty'.
