%%
%% This is file `nameauth.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nameauth.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2011 by Charles P. Schaum <charles dot schaum at att dot net>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{nameauth}
    [2012/03/08 v1.1 name authority macros to aid consistent display and indexing of names]
 %
%% \DescribeMacro{\IndexActive}
\newif\if@nameauth@DoFormat
\newif\if@nameauth@DoIndex
\newif\if@nameauth@DoComma
\newif\if@nameauth@Comma
\newif\if@nameauth@Punct
\newif\if@nameauth@DoCaps
\DeclareOption{mainmatter}{\@nameauth@DoFormattrue}
\DeclareOption{frontmatter}{\@nameauth@DoFormatfalse}
\DeclareOption{smallcaps}{\newcommand{\NamesFormat}{\scshape}}
\DeclareOption{italic}{\renewcommand{\NamesFormat}{\itshape}}
\DeclareOption{boldface}{\renewcommand{\NamesFormat}{\bfseries}}
\DeclareOption{noformat}{\renewcommand{\NamesFormat}{}}
\DeclareOption{comma}{\@nameauth@DoCommatrue}
\DeclareOption{nocomma}{\@nameauth@DoCommafalse}
\DeclareOption{index}{\@nameauth@DoIndextrue}
\DeclareOption{noindex}{\@nameauth@DoIndexfalse}
\ExecuteOptions{smallcaps,mainmatter,nocomma,index}
\ProcessOptions\relax
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\newcommand*{\@nameauth@CleanName}[1]%
{%
    \expandafter\zap@space\detokenize{#1} \@empty%
}
\newcommand*{\@nameauth@Root}[1]%
{%
     \@nameauth@TrimRoot#1\relax%
}
\def\@nameauth@TrimRoot#1,#2\relax{#1}
\newcommand*{\@nameauth@Suffix}[1]%
{%
     \@nameauth@TrimSuffix#1\relax%
}
\def\@nameauth@TrimSuffix#1,#2\relax{#2}
\newcommand*{\@nameauth@CheckComma}[1]%
{%
     \@nameauth@CheckSuffix#1,\relax%
}
\def\@nameauth@CheckSuffix#1,#2\relax%
{%
     \def\Test{#2}%
     \ifx\Test\@empty\@nameauth@Commafalse\else\@nameauth@Commatrue\fi%
}
\def\@nameauth@CheckDot{\futurelet\@token\@nameauth@EvalDot}
\def\@nameauth@EvalDot%
{%
    \let\@period=.\ifx\@token\@period\expandafter\@gobble \fi%
}
\newcommand*{\@nameauth@TestDot}[1]%
{%
     \def\TestDot##1.\TestEnd##2\TestStop{\TestPunct{##2}}%
     \def\TestPunct##1%
          {\ifx\TestPunct##1\TestPunct\else\@nameauth@Puncttrue\fi}%
     \@nameauth@Punctfalse%
     \TestDot#1\TestEnd.\TestEnd\TestStop%
}
\DeclareDocumentCommand\@nameauth@FmtName{s m}%
{%
    \@nameauth@DoCapsfalse%
    \@nameauth@TestDot{#2}%
    \IfBooleanTF{#1}%
          {#2}%
          {\bgroup\NamesFormat{#2}\egroup}%
}
\newcommand{\@nameauth@Index}[1]{%
     \if@nameauth@DoIndex\index{#1}\fi%
}
\newcommand*{\@nameauth@CapRoot}[1]%
{%
     \@nameauth@CR#1\relax%
}
\def\@nameauth@CR#1#2\relax{\uppercase{#1}\@nameauth@Root{#2}}
\newcommand{\CapThis}%
{%
     \@nameauth@DoCapstrue%
}
\DeclareDocumentCommand\Name{s o m o}%
{%
     \protected@edef\Surnames{#3}%
     \if@nameauth@DoCaps%
          \protected@edef\Shortnames{\@nameauth@CapRoot{#3,}}%
     \else%
          \protected@edef\Shortnames{\@nameauth@Root{#3,}}%
     \fi%
     \if@nameauth@DoComma\else%
          \@nameauth@CheckComma{#3}%
          \if@nameauth@Comma%
               \protected@edef\Surnames{\@nameauth@Root{#3}\@nameauth@Suffix{#3}}%
          \fi%
     \fi%
     \IfValueTF{#2}%
     {\IfValueTF{#4}%
          {\def\Forenames{#4}}{\def\Forenames{#2}}%
     \ifcsname\@nameauth@CleanName{#2#3!PN!}\endcsname%
          \expandafter\@nameauth@FmtName\expandafter*\expandafter{%
               \expandafter\Forenames\expandafter\space\Surnames}%
          \PackageWarning{nameauth}%
          {macro Name Cross-reference: #2 #3 cannot be a page reference.}%
     \else%
          \if@nameauth@DoFormat%
               \ifcsname\@nameauth@CleanName{#2#3!MN!}\endcsname%
               \IfBooleanTF{#1}%
                    {\expandafter\@nameauth@FmtName\expandafter*\expandafter{%
                         \expandafter\Forenames\expandafter\space\Surnames}%
                         \@nameauth@Index{\Surnames, #2}}%
                    {\expandafter\@nameauth@FmtName\expandafter*\expandafter{\Shortnames}%
                         \@nameauth@Index{\Surnames, #2}}%
               \else%
                    \csgdef{\@nameauth@CleanName{#2#3!MN!}}{}%
                    \expandafter\@nameauth@FmtName\expandafter{%
                         \expandafter\Forenames\expandafter\space\Surnames}%
                         \@nameauth@Index{\Surnames, #2}%
               \fi%
          \else%
               \ifcsname\@nameauth@CleanName{#2#3!NF!}\endcsname%
               \IfBooleanTF{#1}%
                    {\expandafter\@nameauth@FmtName\expandafter*\expandafter{%
                         \expandafter\Forenames\expandafter\space\Surnames}%
                         \@nameauth@Index{\Surnames, #2}}%
                    {\expandafter\@nameauth@FmtName\expandafter*\expandafter{\Shortnames}%
                         \@nameauth@Index{\Surnames, #2}}%
               \else%
                    \csgdef{\@nameauth@CleanName{#2#3!NF!}}{}%
                    \expandafter\@nameauth@FmtName\expandafter*\expandafter{%
                         \expandafter\Forenames\expandafter\space\Surnames}%
                         \@nameauth@Index{\Surnames, #2}%
               \fi%
          \fi%
     \fi}%
     {\IfValueTF{#4}
          {\ifcsname\@nameauth@CleanName{#3#4!PN!}\endcsname%
               \expandafter\@nameauth@FmtName\expandafter*%
                    \expandafter{\Surnames\space#4}%
               \PackageWarning{nameauth}%
               {macro Name Cross-reference: #3 #4 cannot be a page reference.}%
          \else%
               \if@nameauth@DoFormat%
                    \ifcsname\@nameauth@CleanName{#3#4!MN!}\endcsname%
                    \IfBooleanTF{#1}%
                         {\expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames\space#4}%
                              \@nameauth@Index{\Surnames\space#4}}%
                         {\expandafter\@nameauth@FmtName\expandafter*\expandafter{\Shortnames}%
                              \@nameauth@Index{\Surnames\space#4}}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#3#4!MN!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter{%
                              \Surnames\space#4}%
                              \@nameauth@Index{\Surnames\space#4}%
                     \fi%
               \else%
                    \ifcsname\@nameauth@CleanName{#3#4!NF!}\endcsname%
                    \IfBooleanTF{#1}%
                         {\expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames\space#4}%
                              \@nameauth@Index{\Surnames\space#4}}%
                         {\expandafter\@nameauth@FmtName\expandafter*\expandafter{\Shortnames}%
                              \@nameauth@Index{\Surnames\space#4}}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#3#4!NF!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames\space#4}%
                              \@nameauth@Index{\Surnames\space#4}%
                     \fi%
               \fi%
          \fi}%
          {\ifcsname\@nameauth@CleanName{#3!PN!}\endcsname%
               \expandafter\@nameauth@FmtName\expandafter*%
                    \expandafter{\Surnames}%
               \PackageWarning{nameauth}%
               {macro Name Cross-reference: #3 cannot be a page reference.}%
          \else%
               \if@nameauth@DoFormat%
                    \ifcsname\@nameauth@CleanName{#3!MN!}\endcsname%
                    \IfBooleanTF{#1}%
                         {\expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames}%
                              \@nameauth@Index{\Surnames}}%
                         {\@nameauth@FmtName*{\Shortnames}%
                              \@nameauth@Index{\Surnames}}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#3!MN!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter{\Surnames}%
                              \@nameauth@Index{\Surnames}%
                     \fi%
               \else%
                    \ifcsname\@nameauth@CleanName{#3!NF!}\endcsname%
                    \IfBooleanTF{#1}%
                         {\expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames}%
                              \@nameauth@Index{\Surnames}}%
                         {\@nameauth@FmtName*{\Shortnames}%
                              \@nameauth@Index{\Surnames}}%
                     \else%
                         \csgdef{\@nameauth@CleanName{#3!NF!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames}%
                              \@nameauth@Index{\Surnames}%
                    \fi%
               \fi%
          \fi}%
     }%
     \if@nameauth@Punct\expandafter\@nameauth@CheckDot\fi%
}
\DeclareDocumentCommand\FName{o m o}%
{%
     \protected@edef\Surnames{#2}%
     \if@nameauth@DoComma\else%
          \@nameauth@CheckComma{#2}%
          \if@nameauth@Comma%
               \protected@edef\Surnames{\@nameauth@Root{#2}\@nameauth@Suffix{#2}}%
          \fi%
     \fi%
    \IfValueTF{#1}%
     {\IfValueTF{#3}{\edef\Forenames{#3}}{\edef\Forenames{#1}}%
     \ifcsname\@nameauth@CleanName{#1#2!PN!}\endcsname%
          \expandafter\@nameauth@FmtName\expandafter*%
               \expandafter{\Forenames}%
          \PackageWarning{nameauth}%
          {macro FName Cross-reference: #1 #2 cannot be a page reference.}%
     \else%
          \if@nameauth@DoFormat%
               \ifcsname\@nameauth@CleanName{#1#2!MN!}\endcsname%
                    \expandafter\@nameauth@FmtName\expandafter*%
                         \expandafter{\Forenames}%
                    \@nameauth@Index{\Surnames, #1}%
               \else%
                    \csgdef{\@nameauth@CleanName{#1#2!MN!}}{}%
                    \expandafter\@nameauth@FmtName\expandafter{%
                        \expandafter\Forenames\expandafter\space\Surnames}%
                    \@nameauth@Index{\Surnames, #1}%
               \fi%
          \else%
               \ifcsname\@nameauth@CleanName{#1#2!NF!}\endcsname%
                   \expandafter\@nameauth@FmtName\expandafter*%
                         \expandafter{\Forenames}%
                   \@nameauth@Index{\Surnames, #1}%
               \else%
                    \csgdef{\@nameauth@CleanName{#1#2!NF!}}{}%
                    \expandafter\@nameauth@FmtName\expandafter*%
                         \expandafter{\Forenames\expandafter\space\Surnames}%
                    \@nameauth@Index{\Surnames, #1}%
               \fi%
          \fi%
     \fi}%
     {\IfValueTF{#3}
          {\ifcsname\@nameauth@CleanName{#2#3!PN!}\endcsname%
               \expandafter\@nameauth@FmtName\expandafter*%
                    \expandafter{\Surnames\space#3}%
               \PackageWarning{nameauth}%
               {macro FName Cross-reference: #2 #3 cannot be a page reference.}%
          \else%
               \if@nameauth@DoFormat%
                    \ifcsname\@nameauth@CleanName{#2#3!MN!}\endcsname%
                         \@nameauth@FmtName*{\@nameauth@Root{#2,}}%
                         \@nameauth@Index{\Surnames\space#3}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#2#3!MN!}}{}%
                         \expandafter\@nameauth@FmtName%
                              \expandafter{\Surnames\space#3}%
                         \@nameauth@Index{\Surnames\space#3}%
                     \fi%
               \else%
                    \ifcsname\@nameauth@CleanName{#2#3!NF!}\endcsname%
                         \@nameauth@FmtName*{\@nameauth@Root{#2,}}%
                         \@nameauth@Index{\Surnames\space#3}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#2#3!NF!}}{}%
                              \expandafter\@nameauth@FmtName\expandafter*%
                         \expandafter{\Surnames\space#3}%
                         \@nameauth@Index{\Surnames\space#3}%
                     \fi%
               \fi%
          \fi}%
          {\ifcsname\@nameauth@CleanName{#2!PN!}\endcsname%
               \expandafter\@nameauth@FmtName\expandafter*%
                    \expandafter{\Surnames}%
               \PackageWarning{nameauth}%
               {macro FName Cross-reference: #2 cannot be a page reference.}%
          \else%
               \if@nameauth@DoFormat%
                    \ifcsname\@nameauth@CleanName{#2!MN!}\endcsname%
                         \@nameauth@FmtName*{\@nameauth@Root{#2,}}%
                         \@nameauth@Index{\Surnames}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#2!MN!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter{\Surnames}%
                         \@nameauth@Index{\Surnames}%
                     \fi%
               \else%
                    \ifcsname\@nameauth@CleanName{#2!NF!}\endcsname%
                         \@nameauth@FmtName*{\@nameauth@Root{#2,}}%
                         \@nameauth@Index{\Surnames}%
                     \else%
                         \csgdef{\@nameauth@CleanName{#2!NF!}}{}%
                         \expandafter\@nameauth@FmtName\expandafter*%
                              \expandafter{\Surnames}%
                         \@nameauth@Index{\Surnames}%
                    \fi%
               \fi%
          \fi}%
     }%
     \if@nameauth@Punct\expandafter\@nameauth@CheckDot\fi%
}
\DeclareDocumentCommand\AKA{s o m o m o}%
{%
     \protected@edef\Surnamesi{#3}%
     \protected@edef\Surnamesii{#5}%
     \if@nameauth@DoComma\else%
          \@nameauth@CheckComma{#3}%
          \if@nameauth@Comma%
               \protected@edef\Surnamesi{\@nameauth@Root{#3}\@nameauth@Suffix{#3}}%
          \fi%
          \@nameauth@CheckComma{#5}%
          \if@nameauth@Comma%
               \protected@edef\Surnamesii{\@nameauth@Root{#5}\@nameauth@Suffix{#5}}%
          \fi%
     \fi%
     \IfValueTF{#4}%
     {\IfValueTF{#6}%
          {\edef\Forenames{#6}}{\edef\Forenames{#4}}%
          \expandafter\@nameauth@FmtName\expandafter*\expandafter{%
               \expandafter\Forenames\expandafter\space\Surnamesii}%
          \ifcsname\@nameauth@CleanName{#4#5!PN!}\endcsname%
               \PackageWarning{nameauth}%
               {macro AKA XRef: #4 #5 exists.}%
          \else%
               \ifcsname\@nameauth@CleanName{#4#5!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro AKA Name reference: #4 #5 already exists; no see ref.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#4#5!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro AKA Name reference: #4 #5 already exists; no see ref.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#4#5!PN!}}{}%
                         \IfValueTF{#2}%
                              {\@nameauth@Index{\Surnamesii, #4|see{\Surnamesi, #2}}}%
                              {\@nameauth@Index{\Surnamesii, #4|see{\Surnamesi}}}%
                    \fi%
               \fi%
          \fi}%
     {\IfValueTF{#6}%
          {\IfBooleanTF{#1}%
               {\@nameauth@FmtName*{#6}}%
               {\expandafter\@nameauth@FmtName\expandafter*%
                    \expandafter{\Surnamesii\space#6}}%
          \ifcsname\@nameauth@CleanName{#5#6!PN!}\endcsname%
               \PackageWarning{nameauth}%
               {macro AKA XRef: #5 #6 exists.}%
          \else%
               \ifcsname\@nameauth@CleanName{#5#6!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro AKA Name reference: #5 #6 already exists; no see ref.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#5#6!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro AKA Name reference: #5 #6 already exists; no see ref.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#5#6!PN!}}{}%
                         \IfValueTF{#2}%
                              {\@nameauth@Index{\Surnamesii\space#6|see{\Surnamesi, #2}}}%
                              {\@nameauth@Index{\Surnamesii\space#6|see{\Surnamesi}}}%
                    \fi%
               \fi%
          \fi}%
          {\expandafter\@nameauth@FmtName\expandafter*\expandafter{\Surnamesii}%
          \ifcsname\@nameauth@CleanName{#5!PN!}\endcsname%
               \PackageWarning{nameauth}%
               {macro AKA XRef: #5 exists.}%
          \else%
               \ifcsname\@nameauth@CleanName{#5!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro AKA Name reference: #5 already exists; no see ref.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#5!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro AKA Name reference: #5 already exists; no see ref.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#5!PN!}}{}%
                         \IfValueTF{#2}%
                              {\@nameauth@Index{\Surnamesii|see{\Surnamesi, #2}}}%
                              {\@nameauth@Index{\Surnamesii|see{\Surnamesi}}}%
                    \fi%
               \fi%
          \fi}%
     }%
     \if@nameauth@Punct\expandafter\@nameauth@CheckDot\fi%
}
\DeclareDocumentCommand\PName{s o m o m o}%
{%
     \IfBooleanTF{#1}{\Name*[#2]{#3}}{\Name[#2]{#3}}%
     {\space}(\AKA[#2]{#3}[#4]{#5}[#6])%
}
\DeclareDocumentCommand\IndexName{o m o}%
{%
     \protected@edef\Surnames{#2}%
     \if@nameauth@DoComma\else%
          \@nameauth@CheckComma{#2}%
          \if@nameauth@Comma%
               \protected@edef\Surnames{\@nameauth@Root{#2}\@nameauth@Suffix{#2}}%
          \fi%
     \fi%
     \IfValueTF{#1}%
          {\ifcsname\@nameauth@CleanName{#1#2!PN!}\endcsname%
               \else%
                    \@nameauth@Index{\Surnames, #1}%
               \fi}%
          {\IfValueTF{#3}
               {\ifcsname\@nameauth@CleanName{#2#3!PN!}\endcsname%
               \else%
                    \@nameauth@Index{\Surnames\space#3}%
               \fi}%
               {\ifcsname\@nameauth@CleanName{#2!PN!}\endcsname%
               \else%
                    \@nameauth@Index{\Surnames}%
               \fi}%
          }%
}
\DeclareDocumentCommand\ExcludeName{o m o}%
{%
     \IfValueTF{#1}%
     {%
          \ifcsname\@nameauth@CleanName{#1#2!PN!}\endcsname%
               \PackageWarning{nameauth}%
               {macro ExcludeName XRef: #1 #2 exists.}%
          \else%
               \ifcsname\@nameauth@CleanName{#1#2!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro ExcludeName Reference: #1 #2 already exists; no exclusion.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#1#2!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro ExcludeName Reference: #1 #2 already exists; no exclusion.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#1#2!PN!}}{}%
                    \fi%
               \fi%
          \fi}%
     {\IfValueTF{#3}%
          {\ifcsname\@nameauth@CleanName{#2#3!PN!}\endcsname\relax%
          \else%
               \ifcsname\@nameauth@CleanName{#2#3!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro ExcludeName Reference: #2 #3 already exists; no exclusion.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#2#3!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro ExcludeName Reference: #2 #3 already exists; no exclusion.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#2#3!PN!}}{}%
                    \fi%
               \fi%
          \fi}%
          {\ifcsname\@nameauth@CleanName{#2!PN!}\endcsname\relax%
          \else%
               \ifcsname\@nameauth@CleanName{#2!MN!}\endcsname%
                    \PackageWarning{nameauth}%
                    {macro ExcludeName Reference: #2 already exists; no exclusion.}%
               \else%
                    \ifcsname\@nameauth@CleanName{#2!NF!}\endcsname%
                         \PackageWarning{nameauth}%
                         {macro ExcludeName Reference: #2 already exists; no exclusion.}%
                    \else%
                         \csgdef{\@nameauth@CleanName{#2!PN!}}{}%
                    \fi%
               \fi%
          \fi}%
     }%
}
\DeclareDocumentCommand\ForgetName{o m o}%
{%
     \IfValueTF{#1}%
          {\csundef{\@nameauth@CleanName{#1#2!MN!}}%
          \csundef{\@nameauth@CleanName{#1#2!NF!}}}%
          {\IfValueTF{#3}%
               {\csundef{\@nameauth@CleanName{#2#3!MN!}}%
               \csundef{\@nameauth@CleanName{#2#3!NF!}}}%
               {\csundef{\@nameauth@CleanName{#2!MN!}}%
               \csundef{\@nameauth@CleanName{#2!NF!}}}%
          }%
}
\DeclareDocumentCommand\SubvertName{o m o}%
{%
     \IfValueTF{#1}%
          {\csgdef{\@nameauth@CleanName{#1#2!MN!}}%
          \csgdef{\@nameauth@CleanName{#1#2!NF!}}}%
          {\IfValueTF{#3}%
               {\csgdef{\@nameauth@CleanName{#2#3!MN!}}%
               \csgdef{\@nameauth@CleanName{#2#3!NF!}}}%
               {\csgdef{\@nameauth@CleanName{#2!MN!}}%
               \csgdef{\@nameauth@CleanName{#2!NF!}}}%
          }%
}
\newcommand{\NamesInactive}{\@nameauth@DoFormatfalse}
\newcommand{\NamesActive}{\@nameauth@DoFormattrue}
\newcommand{\IndexInactive}{\@nameauth@DoIndexfalse}
\newcommand{\IndexActive}{\@nameauth@DoIndextrue}
\endinput
%%
%% End of file `nameauth.sty'.
