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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
%
%<*other>
%
\ifcat a\noexpand @\let\next\relax\else \def\next{%
\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
\NeedsTeXFormat{LaTeX2e}
\def\filename{kluref.sty}
\def\filedate{2000/04/29}
%\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
%\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
%\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\refstepcounter}
%\DoNotIndex{\normalsize,\numberline,\protect,\endinput}
%\changes{v??}{2000/01/18}{SK: releft etc. now work as advertised}
%\changes{v??}{1998/03/17}{TH: Fixed optional argument to cite for numreferences}
%\changes{v??}{1997/02/18}{TH: Toggled lines for cite definition and citation write (3x)}
%\CodelineIndex
%\newcommand{\Bs}{}
%\parindent=0pt
%\parskip=3pt
%\hfuzz=10pt
%\addtolength{\textwidth}{4pc}
%\MakeShortVerb{\|}
%\begin{document}
%\begin{article}
%\begin{opening}
%\title{\filename}
%\date{\filedate}
%\author{Kluwer Academic Publishers\surname{}}
%\institute{~}
%\begin{abstract}
%This internal stylefile provides commands for references. Options are
%|openbib|, |numreferences| and |namedreferences|. This documentation
%is compiled on |kluwer.cls| to give some examples.
%\end{abstract}
%\end{opening}
%\tableofcontents
%
%\section{Interface}
% This file provides |namedreferences| and |numreferences| options
% for the stylefiles. |namedreferences| use the syntax that is
% explained in the |named.sty| package, but will be repeated
% below. |numreferences| we wrote ourselves, the major difference with
% standard \LaTeX\ iss that the brackets in the `references' section
% have turned into a dot.
% \subsection{Named references}
% This presumes that the reference list you use is sorted
% alphabetically. The general chape of the references section is this:
%
% \begin{verbatim}
% \begin{thebibliography}{}
% \bibitem[\protect\citeauthoryear{author's name}{year}]{key}
% \end{verbatim}
% In a `real' example this is what it looks like:
% \begin{verbatim}
% \begin{thebibliography}{}
%\bibitem[\protect\citeauthoryear{Bisogni~Jr and Arroyo}{1991}]{BJA91}
%J.J. Bisogni~Jr and S.L. Arroyo.
%\newblock The effect of carbon dioxide equilibrium on p{H} in dilute lakes.
%\newblock {\em Water Research}, 25(2):185--190, 1991.
% \end{verbatim}
% This entry was generated by \BibTeX, using the file |named.bst|
% to do the formatting and sorting. This method of generating
% references is highly recommended, because it tends to prevent
% errors. (The |\protect| is only needed if the output is in an
% external file, like the |.bbl| file.) Until we have a `private'
% |.bst| file, |named.bst| is the best option.
%
% Allthough keying this sort of thing in is quite tedious, It also has
% some advantages: this allows you to use some `special' |\cite|
% commands that are normally not available. The following shows what
% the respective commands output on the previous example:
%
% \begin{tabular}{ll} \hline
%Call: &Produces:\\ \hline
%|\cite{BJA91}| &\cite{BJA91}\\
%|\cite*{BJA91}| &\cite*{BJA91}\\
%|\shortcite{BJA91}| &\shortcite{BJA91}\\
%|\citeyear{BJA91}| &\citeyear{BJA91}\\
%|\inlinecite{BJA91}| &\inlinecite{BJA91}\\
%|\opencite{BJA91}| &\opencite{BJA91}
%\end{tabular}
%\section{Implementation}
% From the options follows that the default value is
% |namedreferences|.
%
% \begin{macrocode}
\ProvidesPackage{kluref}[\filedate ]
%</other>
%<*head>
\newif\if@numreferences
\DeclareOption{namedreferences}{\@numreferencesfalse}
\DeclareOption{numreferences}{\@numreferencestrue}
% \end{macrocode}
%
% openbib is ignored (for now ?).
%
% \begin{macrocode}
\DeclareOption{openbib}{}
\ExecuteOptions{namedreferences}
%</head>
%<*other>
\ProcessOptions*
%</other>
%<*main>
% \end{macrocode}
%
%
% |\sectioncmd| is either |\section| or |\chapter|, depending on the used
% major stylefile. Same goes for |\Uppercase|, with regard to pagestyles.
%
%
% \begin{macrocode}
\newenvironment{thebibliography}[1]{%
\sectioncmd*{\refname}\imarkboth{\bibname}{\bibname}%
\footnotesize
\message{\refname}
\def\bibwidthlabel{\releft#1\reright}%
% \end{macrocode}
% |\releft| and |\reright| are usually empty, but they can be defined
% to contain brackets, for instance. This is only useful using
% |numreferences|.
%
% The list and counter are defined below. They vary for the different
% options.
% \begin{macrocode}
\list{\kapbib@counter}{\kapbib@list}
\let\makelabel\@biblabel
\def\newblock{\hskip .11em plus .33em minus .07em}%
\sloppy
\clubpenalty10000
\widowpenalty10000
\sfcode`\.=1000\relax
}{\endlist}
% \end{macrocode}
%
% \subsection{Some utilities}
%
% |\refname| and |\bibname| are not |\providecommand|'s to allow for
% already existing definitions, because we do need to be absolutely
% sure we are in control. That's why they are inside
% |\AtBeginDocument|, to circumvent the |babel| package.
%
% I should ask for french/german names, though.
%
% \begin{macrocode}
\AtBeginDocument{%
\def\refname{References}%
\def\bibname{References}}
% \end{macrocode}
%
%
%
% |\releft| and |\reright| are around the text inside the optional
% argument to |\bibitem|. Together with |\redot|, this allows the
% following hack:
%
%\begin{verbatim}
%\documentclass[numreferences]{kluwer}
%\renewcommand{\releft}{[}
%\renewcommand{\reright}{]}
%\renewcommand{\redot}{}
%\begin{document}
%......
%\begin{thebibliography}{abs}
%\bibitem[abs]{key}...
%\end{verbatim}
%... and the references will look identical to \LaTeX\ Article
% `namedreferences', except for size. Note that this will only work
% using numreferences.
%
% |\coleft| and |\ccright| are the same sort of thing, they allow you
% to change the braces around |\cite| commands into something else:
% ltbibl.dtx contains the following line:
% \begin{verbatim}
% \def\@cite#1#2{[{#1\if@tempswa , #2\fi}]}
% \end{verbatim}
% We redefine this with |\coleft| and |\ccright| for brackets.
%
% This is a hook for klups.sty (oldstyle numerals)
% \begin{macrocode}
\def\i@oldseries{}
% \end{macrocode}
% \begin{macrocode}
\newlength{\bibhang}
\setlength{\bibhang}{14pt}
\newcommand{\redot}{.}
\newcommand{\releft}{}
\newcommand{\reright}{}
\if@numreferences
\def\coleft{[}
\def\ccright{]}
\else
\def\coleft{(}
\def\ccright{)}
\fi
\def\@cite#1#2{\coleft{#1\if@tempswa , #2\fi}\ccright}
% \end{macrocode}
% \begin{macrocode}
\let\oldcite\cite
% \end{macrocode}
% \subsection{Numbered references}
% \begin{macrocode}
\def\numreferences{%
\typeout{KAP -- Numbered references}%
\def\kapbib@counter{\arabic{enumiv}}%
\def\labelsepwidth{1em}%
\def\kapbib@list{%
\setlength{\labelsep}{\labelsepwidth}%
\settowidth{\labelwidth}{\@biblabel{\bibwidthlabel}}%
\setlength{\leftmargin}{\labelwidth}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemindent}{0pt}%
\setlength{\itemsep}{0pt}%
\setlength{\parsep}{0pt}%
\usecounter{enumiv}%
\let\makelabel\kap@biblabel}%
% \end{macrocode}
% This makes flush right labels
% \begin{macrocode}
\def\@biblabel##1{\hfill\releft##1\redot\reright}%
% \end{macrocode}
% |\@bibitem| writes out either |\bibcite{key}{number}| or
% |\bibcite{number}{number}| in case there is no key given. This
% allows |\cite{2}| without a key.
% \begin{macrocode}
\def\@bibitem##1{\item
\def\@tempa{##1}%
\ifx\@tempa\empty
\if@filesw
\immediate\write\@auxout
{\string\bibcite{\thearticle \the\value{\@listctr}}%
{\the\value{\@listctr}}}%
\fi
\else
\if@filesw
\immediate\write\@auxout
{\string\bibcite{\thearticle ##1}{\the\value{\@listctr}}}%
\fi
\fi
\ignorespaces
}%
% \end{macrocode}
% |\@lbibitem| handles the optional argument version.
%
% If no key
% is given, we presume numbered references are really wanted. (It would
% be a bit strange to have entries like |\bibitem[A95]{}| and
% to reference using a counter as in |\cite{1}|).
%
% \begin{macrocode}
\def\@lbibitem[##1]##2{%
\def\@biblabel####1{####1}%
\let\makelabel\@biblabel
\def\@tempa{##2}%
\ifx\@tempa\empty
\item[\@biblabel{\hfill\releft
\arabic{\@listctr}\redot\reright}]%
\if@filesw
{\def\protect####1{\string ####1\space}\immediate
\write\@auxout{\string\bibcite{\thearticle \the\value{\@listctr}}%
{\the\value{\@listctr}}}}%
\fi
% \end{macrocode}
% Otherwise, typeset the argument and write out both argument and key
% to the |.aux| file.
% \begin{macrocode}
\else
\item[\@biblabel{\hfill\releft ##1\redot\reright}]%
\if@filesw
{\def\protect####1{\string ####1\space}\immediate
\write\@auxout{\string\bibcite{\thearticle ##2}{##1}}}%
\fi
\fi
\ignorespaces
}%
% \end{macrocode}
% Now allow some |namedreferences| commands to a least mean something.
% \begin{macrocode}
\let\@internalcite\oldcite
\let\shortcite\@internalcite
\let\citeauthor\@internalcite
\let\citeyear\@internalcite
\let\inlinecite\@internalcite
\let\opencite\@internalcite
\let\cite\@internalcite
\def\citeauthoryear##1##2{}%
% \end{macrocode}
% To end: relatively standard definition of |\@citex|.
% \begin{macrocode}
\def\@citex[##1]##2{%
\let\@citea\@empty
\@cite{\@for\@citeb:=##2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\edef\gl@citeb{\expandafter\@firstofone\@citeb}%
\edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
\@ifundefined{b@\@citeb}{%
\@ifundefined{b@\gl@citeb}{%
\mbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\hbox{\csname b@\gl@citeb\endcsname}}}%
{\hbox{\csname b@\@citeb\endcsname}}%
}}{##1}}
}
% \end{macrocode}
%\subsection{Named references}
% \begin{macrocode}
\def\namedreferences{%
\typeout{KAP -- Named references}%
% \end{macrocode}
% This (having no optional argument and/or key)
% is typically one of those things that happen if you switch from
% |num| to |named|. Just write out something to indicate that there
% may be a problem.
%
% \begin{macrocode}
\def\@bibitem##1{\item
\def\@tempa{##1}%
\ifx\@tempa\empty
\if@filesw \immediate\write\@auxout{%
\string\bibcite{\thearticle ??}{??}}\fi
\else
\if@filesw \immediate\write\@auxout{%
\string\bibcite{\thearticle ##1}{??}}\fi
\fi
\ignorespaces
}%
% \end{macrocode}
% Not having a key probably indicates that the optional argument is
% also wrong, but hey, we can't do everything. At least now |\cite|
% is something useful if you can count very well...
%
% It is also possible
% that the optional argument is empty, but that is never a problem
% because it will not be typeset anyway (|\@biblabel| will gobble the
% argument).
%
% 21/3/1997 inserted increment of |\@listctr| to prevent multiply
% defined labels.
% \begin{macrocode}
\def\@lbibitem[##1]##2{\item[\@biblabel{##1}\hfill]%
\def\@tempa{##2}%
\stepcounter{\@listctr}%
\ifx\@tempa\empty
\if@filesw{\def\protect####1{\string ####1\space}\immediate
\write\@auxout{\string\bibcite{\thearticle
\the\value\@listctr}{##1}}}\fi
\else
\if@filesw{\def\protect####1{\string ####1\space}\immediate
\write\@auxout{\string\bibcite{\thearticle ##2}{##1}}}\fi
\fi
\ignorespaces
}%
\def\labelsepwidth{1em}%
% \end{macrocode}
% Here is the list again. |\bibhang| allows control over the amount
% of hanging indentation.
% \begin{macrocode}
\def\kapbib@counter{\relax }%
\def\kapbib@list{%
\setlength{\labelsep}{0em}%
\setlength{\labelwidth}{0pt}%
\setlength{\itemindent}{-\bibhang}%
\setlength{\itemsep}{0pt}%
\setlength{\parsep}{0pt}%
\usecounter{enumiv}%
\setlength{\leftmargin}{\bibhang}%
\i@oldseries
}%
% \end{macrocode}
% Gobble |\@biblabel|. Also, save meaning of |\cite| for later use.
% \begin{macrocode}
\def\@biblabel##1{}%
\let\@internalcite\oldcite
% \end{macrocode}
% Differences between these |\cite| commands can be seen above.
% \begin{macrocode}
\def\cite{\@ifstar{\citeyear}{\klu@cite}}%
\def\klu@cite{\def\@citeseppen{1000}%
\def\@cite####1####2{\coleft{####1\if@tempswa , ####2\fi}\ccright}%
\def\citeauthoryear####1####2{{\rm\i@oldseries ####1, ####2}}\@internalcite }%
\def\shortcite{\def\@citeseppen{1000}%
\def\@cite####1####2{\coleft{####1\if@tempswa , ####2\fi}\ccright}%
\def\citeauthoryear####1####2{{\rm\i@oldseries ####2}}\@internalcite }%
\def\citeauthor##1{\def\@citeseppen{1000}%
\def\@cite####1####2{{####1\if@tempswa , ####2\fi}}%
\def\citeauthoryear####1####2{\rm ####1}\@citedata{##1}}%
\def\citeyear##1{\def\@citeseppen{1000}%
\def\@cite####1####2{{####1\if@tempswa , ####2\fi}}%
\def\citeauthoryear####1####2{{\rm\i@oldseries ####2}}\@citedata{##1}}%
\def\opencite##1{\citeauthor{##1}, \citeyear{##1}}%
\def\inlinecite##1{\citeauthor{##1} (\citeyear{##1})}%
% \end{macrocode}
% This is rather tricky stuff, these macros come from |named.sty| and
% I remember that I understood them once, but not any more,
% apparantly. Checking this is left as an exersize to the reader.
% \begin{macrocode}
\def\@citedata##1{%
\@tempswafalse%
\let\@citea\@empty
\@cite{\@for\@citeb:=##1\do
{\@citea\def\@citea{,\penalty\@citeseppen\ }%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\edef\gl@citeb{\expandafter\@firstofone\@citeb}%
\edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
\@ifundefined{b@\@citeb}{%
\@ifundefined{b@\gl@citeb}{%
\mbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\csname b@\gl@citeb\endcsname}}%
{\csname b@\@citeb\endcsname}}}{}}
\def\@citex[##1]##2{%
\let\@citea\@empty
\@cite{\@for\@citeb:=##2\do
{\@citea\def\@citea{;\penalty\@citeseppen\ }%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\edef\gl@citeb{\expandafter\@firstofone\@citeb}%
\edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
\@ifundefined{b@\@citeb}{%
\@ifundefined{b@\gl@citeb}{%
\mbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\csname b@\gl@citeb\endcsname}}%
{\csname b@\@citeb\endcsname}}}{##1}}
% \end{macrocode}
% Allow |\citeauthoryear| in |\write|
% \begin{macrocode}
\def\citeauthoryear##1##2{\string\citeauthoryear{##1}{##2}}}
%%%%%%%%%%%%%%%%%%%%%%%%%
\if@numreferences
\numreferences
\else
\namedreferences
\fi
%</main>
%<*other>
\endinput
% \end{macrocode}
%\begin{thebibliography}{}
%\bibitem[\citeauthoryear{Bisogni~Jr and Arroyo}{1991}]{BJA91}%
%J.J. Bisogni~Jr and S.L. Arroyo.
%\newblock The effect of carbon dioxide equilibrium on p{H} in dilute lakes.
%\newblock {\em Water Research}, 25(2):185--190, 1991.
%\end{thebibliography}
%\PrintIndex
%\end{article}
%\end{document}
% end of kluref.sty
%</other>
|