summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/nameauth/examples.tex
blob: 85c62eb98f1b31152a1ca1674b6c6afbf4bb0dcd (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
\documentclass{article}
\usepackage{verbatim}
\begin{document}
%% This is an example file used with the nameauth package.
%% See README and nameauth.pdf for copyright info.
%%
\section*{Test for Latex Engine}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     Test which LaTeX engine you are using
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{verbatim}
\usepackage{ifxetex}
\usepackage{ifluatex}
\ifxetex%								uses fontspec
  \usepackage{fontspec}%				check package docs
  \defaultfontfeatures{Mapping=tex-text}
  \usepackage{xunicode}%				check if outmoded
  \usepackage{xltxtra}%					check if outmoded
\else
  \ifluatex%							also uses fontspec
    \usepackage{fontspec}%				check package docs
    \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: $\epsilon$-\TeX}
\begin{verbatim}
\renewcommand*\NamesFormat[1]%
{%
  #1%
  \unless\ifinner
    \marginpar{\raggedleft\scriptsize #1}%
  \fi
}
\end{verbatim}
\section*{First Use in Margin: Historic \TeX}
\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: $\epsilon$-\TeX}
\begin{verbatim}
\newif\ifNoTag
\makeatletter
\renewcommand*\NamesFormat[1]{\begingroup%
  \protected@edef\temp{\endgroup\textbf{#1}%
  \unless\ifNoTag
    \if@nameauth@InName
      {\bfseries\noexpand\NameQueryInfo
      [\unexpanded\expandafter{\the\@nameauth@toksa}]
      {\unexpanded\expandafter{\the\@nameauth@toksb}}
      [\unexpanded\expandafter{\the\@nameauth@toksc}]}\fi
    \if@nameauth@InAKA
      \noexpand\NameQueryInfo
      [\unexpanded\expandafter{\the\@nameauth@toksa}]
      {\unexpanded\expandafter{\the\@nameauth@toksb}}
      [\unexpanded\expandafter{\the\@nameauth@toksc}]\fi
  \fi}\temp\global\NoTagfalse}
\makeatother
\end{verbatim}
\section*{Text Tag With First Use: Historic \TeX}
\begin{verbatim}
\newif\ifNoTag
\makeatletter
\renewcommand*\NamesFormat[1]{%
  \let\ex\expandafter%
  #1%
  \if@nameauth@InName
    \ifNoTag
    \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
    \ifNoTag
    \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\NoTagfalse}
\makeatother
\end{verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     Surname index entries in an fbox
%%     First surname instances in text are in an fbox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% We create a macro \Fbox that prints its argument in a framed
%% box when \@nameauth@DoAlt is true, or it just prints its argument.
%%
%%
\section*{Formatting and Capping: New Style}
\begin{verbatim}
\makeatletter
\newcommand*\Fbox[1]{%
  \if@nameauth@DoAlt
    \fbox{#1}\else#1\fi
}
\makeatother

\renewcommand*\MainNameHook[1]{\NameOnly\NameParser}

\let\FrontNameHook\MainNameHook
\end{verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     Use both the arguments passed to the hooks
%%     and \NameParser under different conditions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% We redefine the hooks to print a name in the text and in
%% a margin paragraph. We change some of the internal flags
%% to make \NameParser print the name differently.
%%
%%
\section*{Putting \texttt{\textbackslash NameParser} on Display}
\begin{verbatim}
\makeatletter
\renewcommand*\NamesFormat[1]{%
  #1\unless\ifinner
    \marginpar{\small\raggedleft%
               \@nameauth@FullNametrue%
               \@nameauth@FirstNamefalse%
               \@nameauth@EastFNfalse%
               \NameParser}%
  \fi}
\renewcommand*\MainNameHook[1]{%
  \AltOff#1\unless\ifinner
    \marginpar{\small\raggedleft%
               \@nameauth@FullNamefalse%
               \@nameauth@FirstNamefalse%
               \@nameauth@EastFNfalse%
               \NameParser}%
  \fi}
\makeatother
\end{verbatim}
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     Surname index entries in an fbox
%%     First surname instances in text are in an fbox
%%     We can capitalize name within that formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Below we create a Boolean value \ifFbox and set it true.
%% This will trigger an fbox
%%
%% We then create a macro \Fbox that prints its argument in 
%% an fbox when \ifFbox is true, or makes no change otherwise.
%%
%% The \AltCap macro only capitalizies its argument inside the formatting
%% hook \NamesFormat below.
%%
%% \Namesformat ignores its argument, sets \InHooktrue, then
%% calls the name parser used specifically in formatting hooks.
%%
%%
\section*{Formatting and Capping: Old Style}
\begin{verbatim}
\newif\ifFbox
\newif\ifFirstCap
\newif\ifInHook
\Fboxtrue

\renewcommand*\Fbox[1]{%
  \ifFbox\fbox{#1}\else#1\fi
}

\renewcommand*\AltCap[1]{%
  \ifInHook
    \ifFirstCap\uppercase{#1}\else#1\fi
  \else
    #1%
  \fi
}

\renewcommand\CapThis{\FirstCaptrue}

\renewcommand*\NamesFormat[1]
{%
  \InHooktrue\NameParser\InHookfalse%
  \global\FirstCapfalse%
}

\renewcommand*\MainNameHook[1]
{%
  \Fboxfalse\InHooktrue\NameParser\InHookfalse%
  \global\FirstCapfalse\Fboxtrue%
}

\let\FrontNamesFormat\Namesformat
\let\FrontNameHook\MainNameHook
\end{verbatim}
\end{document}