%%% ====================================================================
%%%  @LaTeX-file{
%%%     filename  = "amsbooka.dtx",
%%%     version   = "2.06",
%%%     date      = "2008/05/19",
%%%     time      = "09:46:14 EDT",
%%%     author    = "American Mathematical Society",
%%%     copyright = "Copyright 1995, 2008 American Mathematical Society.
%%%                  Licensed under the LaTeX Project Public License
%%%                  version 1.3c or (at your option) any later version.
%%%                  The latest version of this license is in
%%%                  http://www.latex-project.org/lppl.txt
%%%                  If you make any changes, please rename it to
%%%                  some other name.",
%%%     address   = "American Mathematical Society,
%%%                  Publications Technical Group,
%%%                  201 Charles Street,
%%%                  Providence, RI 02904-2294,
%%%                  USA",
%%%     telephone = "401-455-4080 or (in the USA and Canada)
%%%                  800-321-4AMS (321-4267)",
%%%     FAX       = "401-331-3842",
%%%     checksum  = "07052 384 1313 12859",
%%%     email     = "tech-support@ams.org",
%%%     codetable = "ISO/ASCII",
%%%     keywords  = "latex, amslatex, ams-latex, monograph",
%%%     supported = "yes",
%%%     abstract  = "This is part of the AMS-\LaTeX{} distribution.
%%%                  It contains code to augment the AMS-\LaTeX{}
%%%                  monograph document classes, providing the ability
%%%                  to include an author's name along with a chapter
%%%                  title, and to pass the author information along
%%%                  for inclusion in the table of contents",
%%%     docstring = "The checksum field above contains a CRC-16
%%%                  checksum as the first value, followed by the
%%%                  equivalent of the standard UNIX wc (word
%%%                  count) utility output of lines, words, and
%%%                  characters.  This is produced by Robert
%%%                  Solovay's checksum utility.",
%%%  }
%%% ====================================================================
% \iffalse
%<*driver>
\documentclass{amsdtx}
\begin{document}
\title{The \pkg{amsbooka} package}
\author{American Mathematical Society\\Barbara Beeton}
\date{Version \fileversion, \filedate}
\hDocInput{amsbooka.dtx}
\end{document}
%</driver>
% \fi
%
% \maketitle
%
% \MakeShortVerb\|
%
% \section{Introduction}
%
%    This package is an add-on to the \amslatex/ document classes for
%    monographs.  It provides the facility to include an author's name
%    with a part or chapter title of a monograph, and automatically pass
%    the author information on to the table of contents for presentation
%    in a style compatible with the regular (series-specific) TOC style.
%
%    This package may become part of the \amslatex/ collection of
%    document classes and related packages.
%
% \StopEventually{}
%
%    Standard file identification.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]% LaTeX date must December 1994 or later
\ProvidesPackage{amsbooka}[2008/05/19 v2.06 monograph part/chapter authors]
%    \end{macrocode}
%
% \section{User instructions}
%
%    A part or chapter with no associated author is input in the usual
%    way:\\
%    \verb|\part{full title}|\\
%    \verb|\chapter[short title]{full title}|\\
%    The part or chapter title will be set in the regular style for
%    the series.
%
%    If an author is to be associated with a chapter, then the short
%    title \emph{must} be provided, and the author is included within
%    the full title, thus:\\
%    \verb|\chapter[short title]{full title \author{author name}}|\\
%    This works for both \verb|\chapter| and \verb|\chapter*|.
%    Similarly, a part title with an associated author must include
%    the author as follows:\\
%    \verb|\part{full title \author{author name}}|\\
%    No short title is required for a part title with author.
%
%    The author name will be set following the title and also included
%    in the table of contents, both in the appropriate style for the
%    series.
%
%    The front matter of the book must include (at least) a \cn{title}
%    and \cn{\maketitle}.  If these are absent, an unintelligible error
%    message will result.
%
%
% \section{Implementation}
%
%    This package is meant for use with all AMS monograph series.
%    Two series, GSM and STML, have special requirements, so provide
%    matching strings that can be used to identify them.
%    \begin{macrocode}
\def\@gsm{gsm-l}
\def\@stml{stml-l}
%    \end{macrocode}
%
% \subsection{Chapter headings}
%
%  \begin{macro}{@schaptera}
%  \begin{macro}{@schapterb}
%    In order to associate an author name with an unnumbered chapter,
%    we need to redefine \cs{@schapter} to accept a bracketed optional
%    version for the running head.  The original version, without
%    optional text, is still required for the bibliography and index
%    as well as for other unauthored chapters.  Use the original
%    \cs{@schapter} for this by giving it another name, and check
%    again for the presence of a bracketed option.
%    \begin{macrocode}
\let\@schapterb\@schapter
\def\@schapter{\secdef\@schaptera\@schapterb}
\def\@schaptera[#1]#2{\typeout{#1}%
  \let\@secnumber\@empty
  \def\@toclevel{0}%
  \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#2}%
  \else \@tocwriteb\tocchapter{chapter}{#2}\fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \@makeschapterhead{#2}\@afterheading
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{@makechapterhead}
%  \begin{macro}{@makeschapterhead}
%    Redefine the commands \cs{@makechapterhead} and \cs{@makeschapterhead}
%    from the regular monograph document classes, handling special cases
%    as necessary.
%    \begin{macrocode}
\def\@makechapterhead#1{%
  \ifx\@classname\@gsm \@makegsmchapterhead{#1}%
  \else \ifx\@classname\@stml \@makestmlchapterhead{#1}%
  \else \@makeplainchapterhead{#1}%
  \fi \fi
}
\newif\if@schapter \@schapterfalse
\def\@makeschapterhead#1{%
  \@schaptertrue
  \ifx\@classname\@gsm \@makegsmchapterhead{#1}%
  \else \ifx\@classname\@stml \@makestmlchapterhead{#1}%
  \else \@makeplainschapterhead{#1}%
  \fi \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{@makeplainchapterhead}
%  \begin{macro}{@makeplainschapterhead}
%    The ``plain'' chapter head style is used for nearly all AMS
%    monograph series.  The title is set in the usual style, with
%    the author name centered below in small caps.
%    \begin{macrocode}
\def\@makeplainchapterhead#1{%
  \global\topskip 7.5pc\relax
  \begingroup
  \def\title{}%
  \def\author##1{\vskip1pc\fontsize{\@xiipt}{14}\mdseries\textsc{##1}}%
  \fontsize{\@xivpt}{18}\bfseries\centering
    \ifnum\c@secnumdepth>\m@ne
      \leavevmode \hskip-\leftskip
      \rlap{\vbox to\z@{\vss
          \centerline{\normalsize\mdseries
              \MakeUppercase{\chaptername}\enspace\thechapter}
          \vskip 3pc}}\hskip\leftskip
    \fi
    #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \vskip\skip@
}
\def\@makeschapterhead#1{\global\topskip 7.5pc\relax
  \begingroup
  \def\title{}%
  \def\author##1{\vskip1pc\fontsize{\@xiipt}{14}\mdseries\textsc{##1}}%
  \fontsize{\@xivpt}{18}\bfseries\centering
  #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \vskip\skip@
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{@makeruledchapterhead}
%  \begin{macro}{@makeruledschapterhead}
%    GSM and STML require a rule at the top of the page and a smaller
%    rule above the page number at the bottom.  Other specs are
%    publication-specific.
%    \begin{macrocode}
\def\@makeruledchapterhead#1{%
  \global\topskip\normaltopskip
  \begingroup
  \def\author##1{\\ \hfil \\ \@chapauthorstyle ##1}%
  \vbox to\topskip{%
    \chapter@number
    \vss
  }\penalty\@M
  \@chapheadstyle \raggedright
  \noindent #1\par \endgroup
  \if@index
    \@indexstyle
  \else
    \@dropfolio
    \@noindexstyle
  \fi
  \@afterheading
}
\def\@makeruledschapterhead#1{%
  \global\topskip\normaltopskip
  \begingroup
  \def\author##1{\\ \hfil \\ \@chapauthorstyle ##1}%
  \@chapheadstyle \raggedright
  \noindent #1\par \endgroup
  \if@index
    \@indexstyle
  \else
    \@dropfolio
    \@noindexstyle
  \fi
  \@afterheading
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{@makegsmchapterhead}
%    The style for GSM requires a rule at the top of the page, with
%    the chapter title flush left, bold, and the author information
%    below the title also flush left and bold but in a smaller size.
%    \begin{macrocode}
\def\@makegsmchapterhead#1{%
  \def\@chapheadstyle{\Huge\bfseries \hsize24pc
    \top@space{11pc}}%
  \def\@chapauthorstyle{\LARGE\bfseries}%
  \def\@indexstyle{%
    \ifx\@empty\indexintro
      \bb@space{7.5pc}%
    \else
      \vspace{3pc}%
      \begingroup \small
        \parbox[t]{27pc}{\leftskip3pc\normalfont\indexintro\par}%
      \endgroup
      \bb@space{3pc}%
    \fi
    }%
  \def\@noindexstyle{\bb@space{7.5pc}}%
  \if@schapter
    \@makeruledschapterhead{#1}%
  \else
    \@makeruledchapterhead{#1}%
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%    The style for STML is similar to that for GSM, except for the
%    smaller page size and the author information set in lightface
%    in the LARGE size.
%  \begin{macro}{@makestmlchapterhead}
%    \begin{macrocode}
\def\@makestmlchapterhead#1{%
  \def\@chapheadstyle{\fontsize\@xxpt{22}\selectfont\bfseries\hsize 21pc
    \top@par@space{9pc}}%
  \def\@chapauthorstyle{\LARGE\mdseries}%
  \def\@indexstyle{%
    \ifx\@empty\indexintro
      \bb@par@space{6.5pc}%
    \else
      \vspace{2.5pc}%
      \begingroup \small
        \parbox[t]{22.5pc}{\leftskip2.5pc\normalfont\indexintro\par}%
      \endgroup
      \bb@par@space{2.5pc}%
    \fi
    }%
  \def\@noindexstyle{\bb@par@space{6.5pc}}%
  \if@schapter
    \@makeruledschapterhead{#1}%
  \else
    \@makeruledchapterhead{#1}%
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \subsection{Part headings}
%
%  \begin{macro}{@plainpart}
%    The ``plain'' part head style is used for nearly all AMS
%    monograph series.  The title is set in the usual style, with
%    the author name centered below in italic.
%    \begin{macrocode}
\def\partauthor{%
  \def\author##1{\newline\phantom{Part 1.\enspace}{\mdseries\scshape##1}}}
\def\@part[#1]#2{%
  \ifnum \c@secnumdepth >-2\relax \refstepcounter{part}%
    \addcontentsline{toc}{part}{\partname\ \thepart.%
        \protect\partauthor\protect\enspace\protect\noindent#1}%
  \else
    \addcontentsline{toc}{part}{#1}\fi
  \begingroup
  \def\author##1{\\ \hfil \\ \fontsize{\@xivpt}{20}\mdseries\itshape ##1}%
  \centering
  \ifnum \c@secnumdepth >-2\relax
     {\fontsize{\@xviipt}{22}\bfseries
       \partname\ \thepart} \vskip 20\p@ \fi
  \fontsize{\@xxpt}{25}\bfseries
    #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
\def\@spart#1{\addcontentsline{toc}{part}%
  {\protect\partauthor\protect\noindent#1}%
  \begingroup
  \def\author##1{\\ \hfil \\ \fontsize{\@xivpt}{20}\mdseries\itshape ##1}%
  \centering
  \fontsize{\@xxpt}{25}\bfseries
    #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
%    \end{macrocode}
%  \end{macro}
%
%  \subsection{Table of Contents}
%
%    Allow more space for the page number than provided in \cls{amsbook};
%    that is only 1.6em, and results in unpleasantly long text.
%    \begin{macrocode}
\setbox\z@\hbox{\kern1.5pc 999}
\renewcommand{\@pnumwidth}{\wd\z@}
%    \end{macrocode}
%
%  \begin{macro}{@tocline}
%    Replace the \cs{@tocline} command to include the \cn{author}
%    information.  This will be set in small caps on the line following
%    the chapter title, with the same indentation as the title.
%    \begin{macrocode}
\def\@tocline#1#2#3#4#5#6#7{\relax
  \ifnum #1>\c@tocdepth % then omit
  \else
    \def\author##1{\newline\textsc{##1}}%
    \par \addpenalty\@secpenalty\addvspace{#2}%
    \begingroup \hyphenpenalty\@M
    \@ifempty{#4}{%
      \@tempdima\csname r@tocindent\number#1\endcsname\relax
    }{%
      \@tempdima#4\relax
    }%
    \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
    \rightskip\@pnumwidth plus.2\hsize \parfillskip-\@pnumwidth
    #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
    \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
    \nobreak
    \endgroup
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \subsection{Boilerplate}
%
%    The usual \cs{endinput} to ensure that random garbage at the end of
%    the file doesn't get copied by \fn{docstrip}.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \CheckSum{438}
% \Finale
