% This is an example file used with the nameauth package.
%
%
% Below we print the argument both in the text and in a margin paragraph
% unless we are in internal vertical mode.
%
% This macro is suitable to replace \NamesFormat and \FrontNamesFormat.
%
\renewcommand*\NamesFormat[1]%
{%
  #1%
  \ifinner
  \else
    \marginpar{\raggedleft\scriptsize #1}%
  \fi
}
%
% Below we print the argument in the text and then we query the text tag
% database to see if we can print a text tag after the argument.
%
% This macro is suitable to replace \NamesFormat and \FrontNamesFormat.
%
\newif\ifNoTextTag
\makeatletter
\renewcommand*\NamesFormat[1]%
{%
  \let\ex\expandafter%
  #1%
  \if@nameauth@InName
    \ifNoTextTag
    \else
      \ex\ex\ex\ex\ex\ex\ex\NameQueryInfo\ex\ex\ex\ex\ex\ex\ex[%
        \ex\ex\ex\the\ex\ex\ex\@nameauth@toksa\ex\ex\ex]%
        \ex\ex\ex{\ex\the\ex\@nameauth@toksb\ex}\ex[\the\@nameauth@toksc]%
    \fi
  \fi
  \if@nameauth@InAKA
    \ifNoTextTag
    \else
      \ex\ex\ex\ex\ex\ex\ex\NameQueryInfo\ex\ex\ex\ex\ex\ex\ex[%
        \ex\ex\ex\the\ex\ex\ex\@nameauth@toksa\ex\ex\ex]%
        \ex\ex\ex{\ex\the\ex\@nameauth@toksb\ex}\ex[\the\@nameauth@toksc]%
    \fi
  \fi
  \global\NoTextTagfalse%
}
\makeatother
%
% Below we create a Boolean value \ifSC and set it true.
%
% We then create a macro \DoFormat that prints its argument in 
% small caps if a Boolean value is true, or makes no font change
% and prints the the argument of the value is false.
%
% The next macro ignores its argument, sets \SCfalse, then
% uses some control sequences internal to the naming macros to
% parse and print the current name values without any formatting.
%
% The final macro is suitable to replace \MainNameHook and \FrontNameHook.
%
\makeatletter
\newif\ifSC
\SCtrue
\def\DoFormat#1{%
  \ifSC
    \textsc{#1}%
  \else
    #1%
  \fi
}
\newcommand*\MainNameHook[1]{%
  \let\ex\expandafter%
  \SCfalse\ignorespaces%
  \protected@edef\arga{\ex\trim@spaces\ex{\the\@nameauth@toksa}}%
  \protected@edef\argb{\ex\trim@spaces\ex{\the\@nameauth@toksb}}%
  \protected@edef\testb{\ex\@nameauth@Root\ex{\the\@nameauth@toksb}}%
  \protected@edef\argc{\ex\trim@spaces\ex{\the\@nameauth@toksc}}%
  \ifx\argb\testb
    \protected@edef\Suff{\@empty}%
    \let\Reversed\argb%
    \let\SNN\argb%
    \let\Short\argb%
  \else
    \protected@edef\Suff{\ex\@nameauth@Suffix\ex{\the\@nameauth@toksb}}%
    \protected@edef\Reversed{\Suff\Space\testb}%
    \protected@edef\SNN{\testb\Space\Suff}%
     \if@nameauth@RevThis
       \let\Short\Suff%
     \else
       \let\Short\testb%
     \fi
  \fi
  \if@nameauth@InAKA
    \ifx\arga\@empty
      \ifx\argc\@empty
        \if@nameauth@RevThis
          \Reversed%
        \else
          \SNN%
        \fi
      \else
         \if@nameauth@AltAKA
           \argc%
         \else
           \if@nameauth@RevThis
             \ex\argc\ex\Space\SNN%
           \else
             \ex\SNN\ex\space\argc%
           \fi
         \fi
       \fi
     \else
       \ifx\argc\@empty
         \let\FNN\arga%
       \else
         \let\FNN\argc%
       \fi
       \if@nameauth@AltAKA
         \FNN%
       \else
         \if@nameauth@RevThis
           \ex\SNN\ex\Space\FNN%
         \else
           \ex\FNN\ex\space\SNN%
         \fi
       \fi
     \fi
  \else
    \ifx\arga\@empty
      \ifx\argc\@empty
        \if@nameauth@FullName
          \if@nameauth@RevThis
            \Reversed%
          \else
            \SNN%
          \fi
        \else
          \Short%
        \fi
      \else
        \if@nameauth@FullName
          \if@nameauth@RevThis
            \ex\argc\ex\space\SNN%
          \else
            \ex\SNN\ex\space\argc%
          \fi
        \else
          \if@nameauth@RevThis
            \argc%
          \else
            \Short%
          \fi
        \fi
      \fi
    \else
      \ifx\argc\@empty
        \let\FNN\arga%
      \else
        \let\FNN\argc%
      \fi
      \let\Short\FNN%
      \if@nameauth@FullName
        \if@nameauth@RevThis
          \ex\SNN\ex\Space\FNN%
        \else
          \ex\FNN\ex\space\SNN%
        \fi
      \else
        \if@nameauth@FirstName
          \Short%
        \else
          \testb%
        \fi
      \fi
    \fi
  \fi
}
\makeatother

