summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/nameauth/examples.tex
blob: f469316175f943da2475aa88e7d2ef562acad69f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
\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}