\documentclass{article} \usepackage{verbatim} \begin{document} %% This is an example file used with the nameauth package. %% See README and nameauth.pdf for copyright info. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Test which LaTeX engine you are using %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% \section*{Test for Latex Engine} \begin{verbatim} \usepackage{ifxetex} \usepackage{ifluatex} \ifxetex% uses fontspec \usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text} \usepackage{xunicode} \usepackage{xltxtra} \else \ifluatex% also uses fontspec \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \else% traditional NFSS \usepackage[utf8]{inputenc} \usepackage[TS1,T1]{fontenc} \fi \fi \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Print the first use of a name in text and margin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% 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. %% \section*{First Use in Margin} \begin{verbatim} \renewcommand*\NamesFormat[1]% {% #1% \ifinner \else \marginpar{\raggedleft\scriptsize #1}% \fi } \end{verbatim} \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Print a text tag after first name use %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% 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. %% \section*{Text Tag With First Use} \begin{verbatim} \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 \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Surname index entries in small caps %% First surname instances in text are small caps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Below we create a Boolean value \ifSC and set it true. That means %% the surnames in the index will be in small caps. %% %% We then create a macro \DoFormat that prints its argument in %% small caps if \ifSC is true, or makes no font change %% and prints the the argument. %% %% \MainNameHook ignores its argument, sets \SCfalse to suppress %% small caps in the text only, then calls the name parser used %% specifically in formatting hooks. %% %% The hook macro can replace both \MainNameHook and \FrontNameHook. %% \section*{Continental Small Caps} \begin{verbatim} \makeatletter \newif\ifSC \SCtrue \def\DoFormat#1{% \ifSC \textsc{#1}% \else #1% \fi } \renewcommand*\MainNameHook[1]{\SCfalse\NameParser} \let\FrontNameHook\MainNameHook \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Surname index entries in talic %% First surname instances in text are italic %% Capitalize name within that formatting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Below we create a Boolean value \ifItal and set it true. %% This will trigger italics, similar to the Continental %% example above. %% %% We then create a macro \DoFormat that prints its argument in %% italic when \ifItal is true, or makes no font change otherwise. %% %% The \CP macro only capitalizies its argument inside \NamesFormat below. %% %% \Namesformat ignores its argument, sets \InHooktrue, then %% calls the name parser used specifically in formatting hooks. %% %% The hook macro is suitable to replace \NamesFormat and \FrontNamesFormat. %% To replace \MainNameHook and \FrontNameHook, wrap the hook macro %% between \Italfalse and \italtrue for first-only italic. %% \section*{Formatting and Capping} \begin{verbatim} \newif\ifItal \newif\ifFirstCap \newif\ifInHook \Italtrue \def\DoFormat#1{% \ifItal\textit{#1}\else#1\fi } \def\CP#1{% \ifInHook \ifFirstCap\uppercase{#1}\else#1\fi \else #1% \fi } \newcommand*\CapMe{\FirstCaptrue} \makeatletter% \renewcommand*\NamesFormat[1] {% \InHooktrue\NameParser\InHookfalse% \global\FirstCapfalse% } \renewcommand*\MainNameHook[1] {% \Italfalse\InHooktrue\NameParser\InHookfalse% \global\FirstCapfalse\Italtrue% } \let\FrontNamesFormat\Namesformat \let\FrontNameHook\MainNameHook \end{verbatim} \end{document}