summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cite/cite.sty
blob: 44c37a841df1fd493b3b06b49618ff574e83343d (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
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
%     C I T E . S T Y
%
%     version 5.5  (Feb 2015)
%
%     Compressed, sorted lists of on-line or superscript numerical citations.
%     see also drftcite.sty (And the stub overcite.sty)
%
%     Copyright (C) 1989-2015 by Donald Arseneau
%     These macros may be freely used, transmitted, reproduced, or modified
%     provided that this notice is left intact.
%
%     Instructions in cite.pdf and follow \endinput.
%  ------------------------------------
% First, ensure that some catcodes have the expected values
\edef\citenum{% temporary def to restore funny codes later
  \catcode\string`\string ` \the\catcode\string`\`
  \catcode\string`\string ' \the\catcode\string`\'
  \catcode\string`\string . \the\catcode\string`\.
  \catcode\string`\string = \the\catcode\string`\=
  \catcode\string`\string _ \the\catcode\string`\_
  \catcode\string`\string : \the\catcode\string`\:}
% set  codes:
\catcode\string`\` 12
\catcode`\' 12
\catcode`\. 12
\catcode`\= 12
\catcode`\_ 8  % This is UNusual
\catcode`\: 12

%   Prepare for optional variations:
%   [ verbose, nospace, space, ref, nosort, noadjust, superscript, nomove ],
%   \citeform,\citeleft,\citeright,\citemid,\citepunct,\citedash
%
%   Set defaults first:

%   [ on the left.  Option [ref] does: [Ref. 12, note]
\providecommand\citeleft{[}

%   ] on the right:
\providecommand\citeright{]}

%   , (comma space) before note
\providecommand\citemid{,\penalty\citemidpenalty\ }

%   , (comma thin-space) between entries; [nospace] eliminates the space
\providecommand\citepunct{,\penalty\citepunctpenalty%
        \hskip.13emplus.1emminus.1em\relax}%

%   -- (endash) designating range of numbers:
% (using \hbox avoids easy \exhyphenpenalty breaks)
\providecommand{\citedash}{\hbox{--}\penalty\citepunctpenalty}

% Default line-breaking penalties. Use \mathchardef instead of count registers
\mathchardef\citeprepenalty=\@highpenalty
\mathchardef\citemidpenalty=\@medpenalty
\mathchardef\citepunctpenalty=\@m

%   Each number left as-is:
\providecommand\citeform{}

%   punctuation characters to move for overcite
\providecommand{\CiteMoveChars}{.,:;}

%   font selection for superscript numbers
\providecommand\OverciteFont{\fontsize\sf@size\baselineskip\selectfont}


%   [verbose] is no-op. Default is to repeat warnings anyway.
%\let\oc@verbo\relax

%----------------------
% \citen uses \@nocite to ignore spaces after commas, and write the aux file
% \citation. \citen then loops over the citation tags, using \@make@cite@list
% to make a sorted list of numbers.  Finally, \citen executes \@citelist to
% compress ranges of numbers and print the list. \citen can be used by itself
% to give citation numbers without the brackets and other formatting; e.g.,
% "See also ref.~\citen{junk}."
%  Make internal version called \@cite@n just in case packages put hooks in
%  \citen
%
\DeclareRobustCommand\citen{\@cite@n}
\def\@cite@n#1{%
 \begingroup
  \let\@safe@activesfalse\@empty
  \@nocite{#1}% ignores spaces, writes to .aux file, returns #1 in \@no@sparg
  \@tempcntb\m@ne    % \@tempcntb tracks highest number
  \let\@celt\delimiter % an unexpandable, but identifiable, token
  \def\@cite@list{}% % empty list to start
  \let\@citea\@empty % no punctuation preceding first
  \@for \@citeb:=\@no@sparg\do{\@make@cite@list}% make a sorted list of numbers
  % After sorted citelist is made, execute it to compress citation ranges.
  \@tempcnta\m@ne    % no previous number
  \mathchardef\@cite@incr\z@ % no previous sequence
  \let\@h@ld\@empty  % nothing held from list yet
  \let\@celt\@compress@cite \@cite@list % output number list with compression
  \@h@ld % output anything held over
 \endgroup
 \@restore@auxhandle
 }

% For each citation, check if it is defined. If so, then extract plain
% value to \@B@citeB (without hyperlink info). Then, 
% If it is a pure number, add it to cite list
% Otherwise, try extracting prefix and suffix characters.
%
\def\@make@cite@list{%
 \expandafter\ifx\csname b@\@citeb\@extra@b@citeb 
      \endcsname\relax % undefined: output ? and warning
    \@citea {\bfseries ?}\let\@citea\citepunct \G@refundefinedtrue
    \@warning {Citation `\@citeb' on page \thepage\space undefined}%
 %% always verbose \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}%
 \else %  defined        
    \@cite@nonhyper@sanitize
    \@addto@cite@list
 \fi}

\def\@nonhyper@@link [#1]#2#3#4{#4}
\def\@cite@nonhyper@sanitize{\begingroup
    \let\hyper@@link\@nonhyper@@link
    \protected@xdef\@B@citeB{\csname b@\@citeb\@extra@b@citeb \endcsname}%
  \endgroup}

\def\@cite@out#1{\citeform{\csname #1\endcsname}}

% Add entry to the list of citations.  This default definition sorts pure
% numbers as well as numbers with other single-character tags.  There 
% is presently no other definition than this default, but features may 
% be added later.
%
\def\@addto@cite@list{% 
 \@cite@posnumtest\@B@citeB
   {\@addnumto@cite@list\@B@citeB}%  a positive number, put in list
   {\@cite@combo@num}% not a pure positive number, test for combo forms
}

% With this \@cite@combo@num we delve into handling of numbers combined
% with non-numeric tags.  The specific command name \@cite@combo@num can
% serve as a hook for redefinition, perhaps to give simple non-sorting 
% for anything not a pure number, or to attempt even more complicated
% sorting, say dictionary sorting of textual citations.  The following
% definition leads down the road of sorting mostly-numbers but with 
% optional single-character prefix and/or suffix. 

\def\@cite@combo@num{\expandafter\@cite@try@combo\@B@citeB\delimiter}

% First of many stages for sorting numbers with prefix/suffix characters.
% Test for a leading token of category letter or other (appropriate for
% all combination types).
%
\def\@cite@try@combo{%
  \@if@printable@char{\@cite@try@prefix}{\@cite@gobbledump@now}}

% First token is good, so test for a character prefix before a number.
% Process first token, either a first digit or a prefix
%
\def\@cite@try@prefix#1{% #1 is first character of citation
  \@cite@posnumtest{#1}% a digit else prefix
   {\@cite@add@letnumD {\z@}#1}% no prefix character (use zero)
   {\@cite@add@letnumC {`#1}}% prefix char; use the char code
}

% Examine character after prefix to ensure it is a number.  First must
% ensure it is a plain character token
%
\def\@cite@add@letnumC#1{\@if@printable@char%
   {\@cite@add@letnumD{#1}}% continue with prefix (perhaps zero)
   {\@cite@gobbledump@now}% else abandon fancy processing and output citation
}

% Save prefix (if any) numerically in \@tempcnta, test next character for being
% a digit, then collect main number
%
\def\@cite@add@letnumD#1#2{% #1 = numeric code for prefix, #2 = next char
  \@tempcnta=#1\multiply\@tempcnta 16384 %
  \@cite@posnumtest{#2}% if next char is a digit, continue with number:
   {\afterassignment\@cite@add@letnumE \advance\@tempcnta #2}%
   {\@cite@gobbledump@now}% No number so just output citation
}

% Have collected number.  Now look for a non-number suffix or separator.
%
\gdef\@cite@add@letnumE{%
  \multiply\@tempcnta\@cclvi
  \@if@printable@char{% a suffix or separator given
      \@cite@add@letnumF
    }{% else, maybe nothing remains
      \ifx\@let@token\delimiter % use number, and remove trailing \delimiter
        \@citeaddcnta \expandafter\@gobble
      \else % non-printable char found, so abandon fancy processing
        \expandafter\@cite@gobbledump@now
      \fi
    }}

%  Have everything up to a suffix or separator character.  Check 
%  following to see which. Three possibilites are (1) nothing =>
%  a suffix; (2) number => separator-number; (3) other => garbage.
%
\def\@cite@add@letnumF#1#2\delimiter{% #1 = suffix/separator #2=rest
  \advance\@tempcnta`#1\relax
  \@cite@posnumtest{#2}{\@cite@add@numsepnum{#2}}% handle as num sep num
    {% else...
     \ifx\delimiter#2\delimiter % nothing left, so #1 is a suffix
       \@citeaddcnta
     \else % some non-number; dump it
       \@cite@dump@now
     \fi
}}

% Handle citation as number separator number.
% Yes, there is a bug that the list 1.1,1.258,1.515 will be compressed as
% 1.1-1.515; so sue me.

\def\@cite@add@numsepnum#1{% #1 = last number
  \ifnum\@tempcnta<262144 % OK numeric range
    \multiply\@tempcnta 4096
    \advance\@tempcnta #1 % num,sep,num have maximum numbers:  1023, 255, 4095
    \@citeaddcnta
  \else % out of range, treat as raw string
    \@cite@dump@now
  \fi}

% This is our bail-out when the citation cannot be processed as
% [prefix]number[suffix] or number[sep]number: it outputs the citation 
% immediately (unsorted) and consumes tokens to the \delimiter tag used 
% as an end-marker
%
\def\@cite@gobbledump@now#1\delimiter{\@cite@dump@now}%

\def\@cite@dump@now{%
  \@citea \@cite@out{b@\@citeb\@extra@b@citeb}\let\@citea\citepunct}

% add an entry to the sorted list, using its sort-number \@tempcnta, and
% also saving the plain-text value \@B@citeB as well as the csname 
% b@\@citeb\@extra@b@citeb. (The \@B@citeB is actually not used, unless 
% somebody extends the definitions.)
\def\@citeaddcnta{%
   \ifnum \@tempcnta>\@tempcntb % new highest, add to end (efficiently)
      \edef\@cite@list{\@cite@list 
        \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}%
      \@tempcntb\@tempcnta
   \else % other sortable value: insert appropriately
      \edef\@cite@list{\expandafter\@sort@celt\@cite@list \@gobble.\@gobble.}%
   \fi
  }

% add pure numeric entry to cite list, with sorting
\def\@addnumto@cite@list#1{%
   \@tempcnta#1\relax
   \multiply\@tempcnta\@cclvi
   \@citeaddcnta}

% \@sort@celt inserts number (\@tempcnta) into list of \@celt{num}{text}{tag} 
% (#1{#2}{#3}{#4})
% \@celt must not be expandable, and the arguments must not be fragile. 
% List should end with four vanishing tokens.
%
\def\@sort@celt#1#2#3#4{\ifx \@celt #1% parameters are \@celt{num}{text}{tag}
   \ifnum #2<\@tempcnta % number goes later in list
      \@celt{#2}{#3}{#4}%
      \expandafter\expandafter\expandafter\@sort@celt % continue
   \else % number goes here
      \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}%
      \@celt{#2}{#3}{#4}% stop comparing
\fi\fi}

% Check if each number follows previous and can be put in a range. 
% Since there are suffix characters allowed, there are two kinds of 
% ranges: ranges of consecutive pure numbers with no (or same) 
% suffix, or ranges of the same number with consecutive suffix
% characters.
%
\def\@compress@cite#1#2#3{%% This is executed for each number
  \ifnum\@cite@incr=\z@   % no consecutives pending. Try both types of sequence
    \advance\@tempcnta\@cclvi % Now \@tempcnta has incremented number
    \ifnum #1=\@tempcnta    % Start a sequence of consecutive numbers
       \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}%
       \mathchardef\@cite@incr=\@cclvi
    \else % next try increment of suffix
       \advance\@tempcnta-\@cclv % Now \@tempcnta has incremented suffix
       \ifnum #1=\@tempcnta      % Start a sequence of suffix increments
         \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}%
         \mathchardef\@cite@incr=\@ne
       \else % it is no type of sequence -- emit number (nothing is held)
         \@citea \@cite@out{#3}%
       \fi
    \fi
  \else % a sequence is running
    \advance\@tempcnta\@cite@incr % Now \@tempcnta is next in sequence
    \ifnum #1=\@tempcnta   % Number follows previous--hold on to it
       \def\@h@ld{\citedash \@cite@out{#3}}%
    \else   %  non-successor -- dump what's held and do this one
       \@h@ld \@citea \@cite@out{#3}%
       \let\@h@ld\@empty
       \mathchardef\@cite@incr=\z@
    \fi
  \fi
  \@tempcnta#1\let\@citea\citepunct
}

% Ordinary on-line \cite command

\DeclareRobustCommand{\cite}{%
  \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}

% Do \cite command on line.
%
\def\@citex[#1]#2{\@cite{\@cite@n{#2}}{#1}}

\def\@cite#1#2{\leavevmode \cite@adjust
  \citeleft{#1\if@tempswa\@safe@activesfalse\citemid{#2}\fi
  \spacefactor\@m % punctuation in note doesn't affect outside
  }\citeright
 \@restore@auxhandle}

%  Put a penalty before the citation, and adjust the spacing: if no space
%  already or if there is extra space due to some punctuation, then change
%  to one inter-word space.
%
\def\cite@adjust{\begingroup%
  \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip
  \ifnum\lastpenalty=\z@ \penalty\citeprepenalty \fi
  \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag
  \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi
  \endgroup}

\edef\@zero@skip{\the\z@skip}

% \nocite: This is changed to ignore *ALL* spaces and be robust.  The
% parameter list, with spaces removed, is `returned' in \@no@sparg, which
% is used by \@cite@n (\citen).
%
\DeclareRobustCommand\nocite[1]{%
 \@bsphack \@nocite{#1}%
 \@for \@citeb:=\@no@sparg\do{\@ifundefined{b@\@citeb\@extra@b@citeb}%
    {\G@refundefinedtrue\@warning{Citation `\@citeb' undefined}%
    %%\oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}
    }{}}%
 \@esphack}

\def\@nocite#1{\begingroup\let\protect\string% normalize active chars
 \xdef\@no@sparg{\expandafter\@cite@ignsp#1,\: ,\:}% remove spaces
 \if@filesw \immediate\write\@newciteauxhandle % =\@auxout, except with multibib
    {\string\citation {\@no@sparg}}\fi
 \endgroup}

% remove spaces before and after commas. One level of braces is also
% stripped, so an item {a,b} is changed to two a and b.
%
\def\@cite@ignsp#1 ,#2{\ifx\:#2\@empty 
  \expandafter\@cite@ignsp@\romannumeral-`\:\else
  \expandafter\@cite@ignsp \fi #1,#2}
\def\@cite@ignsp@#1,#2{#1\ifx\:#2\@empty\expandafter\@gobblethree
   \else,\expandafter\@cite@ignsp@\fi #2}

\long\def\@gobblethree #1#2#3{}

% \@if@fillglue{glue}{true}{false}
\begingroup
 \catcode`F=12 \catcode`I=12\catcode`L=12
 \lowercase{\endgroup
 \def\@if@fillglue#1{%
  \begingroup \skip@#1\relax
  \expandafter\endgroup\expandafter 
  \@is@fil@ \the\skip@ \relax\@firstoftwo FIL\relax\@secondoftwo\@nil}
 \def\@is@fil@ #1FIL#2\relax#3#4\@nil{#3}
}

% Test if next token is a char of "printable" categories other or letter or 
% active.  Syntax:
%  \@if@printable@char {do if printable}{do if not printable}<char>
%
\def\@if@printable@char#1#2{%
  \def\reserved@a{#1}%
  \def\reserved@b{#2}%
  \futurelet\@let@token\@test@print@char
}

% Note side-effect of redefining \reserved@a and \reserved@b
\def\@test@print@char{%
 \ifnum 
    \ifcat\noexpand\@let@token A1\fi
    \ifcat\noexpand\@let@token 11\fi
    \ifcat\noexpand\@let@token \noexpand~1\fi%
  0>\z@
    \expandafter\reserved@a \else
    \expandafter\reserved@b \fi
}

% Test for a pure positive number: {possible number}{true}{false}
\def\@cite@posnumtest#1{%
  \ifcat _\ifnum\z@<0#1_\else A\fi
    \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi
}

\let\nocitecount\relax  % in case \nocitecount was used for drftcite

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     option processing
\def\oc@movep{YY}% default Yes move
%
\DeclareOption{verbose}{}% Unused now. Was \def\oc@verbo#1#2#3#4{}
\DeclareOption{nospace}{\def\citepunct{,\penalty\citepunctpenalty}}
\DeclareOption{space}{\def\citepunct{,\penalty\citepunctpenalty\ }}
\DeclareOption{nobreak}{% no line-breaks
 \mathchardef\citeprepenalty=\@M
 \mathchardef\citemidpenalty=\@M
 \mathchardef\citepunctpenalty=\@M
}
\DeclareOption{ref}{\def\citeleft{[Ref.\penalty\@M\ }}
%  To disable sorting [nosort], the redefinition depends on whether [nocompress]
%  was also selected, so just set a flag first.
\DeclareOption{nosort}{\let\@citeaddcnta\@empty}
\DeclareOption{sort}{}% default!
%  Likewise set flag for [nocompress]
\DeclareOption{nocompress}{\let\@compress@cite\@empty}
\DeclareOption{compress}{}% default
\DeclareOption{nomove}{\def\oc@movep{no}}% Flag for later definition
\DeclareOption{move}{\def\oc@movep{YY}}% default
\DeclareOption{super}{\ExecuteOptions{superscript}}
\DeclareOption{superscript}{\let\@citess\cite}% Just a flag redefined below
\DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces
\DeclareOption{adjust}{}% adjust space before [ ]
\DeclareOption{biblabel}{\let\@biblabel\def}% see below
\ProvidesPackage{cite}[2015/02/27 \space v 5.5]
\ProcessOptions

\ifx\@biblabel\def % [biblabel] option 
  \ifx\@citess\cite % [superscript] option
    \def\@biblabel#1{\@citess{#1}\kern-\labelsep\,}
  \else % normal
    \def\@biblabel#1{\citeleft{#1}\citeright}
  \fi
\fi

% Process [superscript] option, and [nomove].

\ifx\@citess\cite 

%  Superscript cite, \cite chooses superscript or on-line-with-note
%
\DeclareRobustCommand{\cite}{%
    \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citew}}

%  Superscript cite, with no optional note.  Check for punctuation first.
\def\@citew#1{\begingroup \leavevmode
  \@if@fillglue \lastskip \relax \unskip
  \def\@tempa{\@tempcnta\spacefactor
     \/% this allows the last word to be hyphenated, and it looks better.
     \@citess{\@cite@n{#1}}\spacefactor\@tempcnta
     \endgroup \@restore@auxhandle}%
  \oc@movep\relax}% check for following punctuation (depending on options)

%  \@citess defines the formatting with superscripts and no brackets.
%  HOWEVER, trailing punctuation has already been moved over.  The
%  format for cites with note is given by \@cite.  Redefine \@cite and/
%  or \@citex to get different appearance.  I don't use \textsuperscript
%  because it is defined BADLY in compatibility mode.

\def\@citess#1{\mbox{$\m@th^{\hbox{\OverciteFont{#1}}}$}}

\if \oc@movep %  Move citation past trailing punctuation; [move] is default

\def\oc@movep#1{\futurelet\@tempb\@citey}
%
\def\@citey{\let\@tempc\@tempa
   % Watch for double periods and suppress them
   \ifx\@tempb.\ifnum\spacefactor<\sfcode`.\else
     \@citeundouble
   \fi\fi
   % Move other punctuation
   \expandafter\@citepc\CiteMoveChars\delimiter
   \@tempc}%

% This is in a separate macro in case the next "character" (token)
% is \if or \fi, etc.
\def\@citeundouble{% Suppress doubling of periods
   \let\@tempb\relax \let\@tempc\oc@movep
}

\def\@citepc#1{%
   \ifx\@tempb#1\@empty #1\let\@tempc\oc@movep \fi
   \ifx\delimiter#1\else \expandafter\@citepc\fi}

%  Set detectable sfcodes when \frenchspacing
\mathchardef\cite@mi1001 % 
\g@addto@macro\frenchspacing
    {\sfcode`\.\cite@mi \sfcode`\?\cite@mi \sfcode`\!\cite@mi }%
\AtBeginDocument {%
  \ifnum\sfcode`\.<1002 \frenchspacing  \let\normalsfcodes\frenchspacing \fi
}% performed after \normalsfcodes defined

\else % [nomove] option:

  \def\oc@movep{\@tempa}
  \let\@citey\relax

\fi % end of move/nomove options
%
\fi %  end [superscript] option processing
%
%  make redefinitions to handle [nosort] [nocompress] and their combination
\ifx\@compress@cite\@empty
   \ifx\@citeaddcnta\@empty
      % [nosort,nocompress] -- short-circuit much processing
      \def\@addto@cite@list{\@cite@dump@now}
   \else
      % [sort,nocompress]
      \def\@compress@cite#1#2#3{%  % This is executed for each number
        \@h@ld \@citea \@cite@out{#3}%
        \let\@h@ld\@empty \let\@citea\citepunct
      }
   \fi
\else %  
   \ifx\@citeaddcnta\@empty % [nosort,compress]
     %  nosort: always add to end of list, but still calculate
     %  sort-order number (\@tempcnta) because it may be used for
     %  collapsing consecutive numbers.
     \def\@citeaddcnta{%
       \edef\@cite@list{\@cite@list 
        \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}%
     }
   \fi
\fi

%  Compatability with chapterbib (see use of \@extra@b@citeb above and in chapterbib)
\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}

%  Compatability with multibib (see use of \@newciteauxhandle) (Yes, this is
%  overly messy, but I asked for it...  I can't have multibib putting junk after 
%  the cite command because it hides following punctuation, but then I have
%  to restore the ordinary meaning of \@newciteauxhandle = \@auxout.)
\providecommand\@newciteauxhandle{\@auxout}
\AtBeginDocument{\@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}}
\def\@restore@auxhandle{\def\@newciteauxhandle{\@auxout}}

%  compatability with backref: prevent it from redefining \@citex
%  in the wrong way (ignoring \@citew and \citen.  I install hook in
%  \@nocite so it applies to \cite, \citen, and \nocite.
%
\AtBeginDocument{\@ifundefined{Hy@backout}{}{%
  \@ifundefined{BRorg@citex}{}{\global\let\@citex\BRorg@citex}%
  \global\let\BR@citex\@citex
  \global\let\@citeorg@nocite\@nocite % use my own hook -> into \@nocite
  \gdef\@nocite#1{\@citeorg@nocite{#1}\Hy@backout{#1}}%
}}

%  compatability with babel:  Prevent it from redefining \@citex
\@ifundefined{@safe@activesfalse}{\let\@safe@activesfalse\relax}{}
\@ifundefined{bbl@cite@choice}{}{\@ifundefined{org@@citex}{}%
  {\let\org@@citex\@citex}}% Prevent stomping by babel

\citenum % execute restore-catcodes

% Aliases:
\def\citenum{\citen}
\def\citeonline{\citen}

\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


                   CITE.STY

Modify LaTeX's normal citation mechanism for improved handling of numeric
citations, behaving as follows:

o Put a comma and a small space between each citation number, allowing 
  line breaks with penalty.

o Compress lists of three or more consecutive numbers, or similar, to a 
  range which can be split, with difficulty, after the dash.  

o Sort citations into ascending order.  

o Sortable and compressible citations are numeric like [5-8]; or numbers 
  with prefix and/or suffix characters like [18a-18c,19] or [A2,Q1,Q3-Q5];
  or two numbers with separator like [1.9-1.12,2.2].

o Allow, but discourage, line breaks within the group of citations (after
  dashes, and after punctuation). 

o Adjust spacing before citation.

o All breaks can be forbidden with the [nobreak] package option.

o With package option [superscript] (or [super] for short), display citations
  as superscripts (unless they have optional notes, causing them to be printed 
  on-line with brackets).  Superscripted citations use THE SAME INPUT FORMAT 
  as ordinary citations; this style will ignore spaces before the \cite command
  and move trailing punctuation before the superscript citation. Doubling of 
  periods (.., ?., !.) is checked for and suppressed. 

o Define \citen to get just the numbers without the brackets or superscript
  and extra formatting.  Aliases are \citenum and \citeonline.

There are several package options for \usepackage{cite}.

 [superscript] use superscrpts for cites without optional notes
 [super]       alias for [superscript] (like natbib)
 [nospace]     eliminates the spaces after commas in the number list
 [space]       uses a full inter-word space after the commas
 [nobreak]     eliminate all line-breaks
 [nosort]      prevents sorting of the numbers (default is to sort, and the...
 [sort]        option is provided for completeness).
 [nomove]      prevents moving the superscript cite after punctuation.
 [move]        is the default
 [noadjust]    disables `smart' handling of space before a cite
 [adjust]      is the default
 [nocompress]  inhibit compression of consecutive numbers into ranges
 [compress]    is the default
 [ref]         uses the format "[Ref.~12, given note]" (useful with [super])
 [biblabel]    define the bibliography label to match \cite

If your citations are not numeric, then you should probably not use 
cite.sty, but if you must, then at least use the [nosort,nocompress] 
options.

See more detailed instructions in cite.pdf (cite.ltx). 


% Version 1991: Ignore spaces after commas in the parameter list. Move most of
% \citen into \@cmpresscites for speed. Give the proper \spacefactor afterwards.
% Version 1992: make \citepunct hold the punctuation between numbers (for ease
% of changing).  Add \/ to allow hyphenation of previous word, and look better
% in italics.
% 1992a: Make it work with NFSS.  (Thank you C. Hamlin and Rainer Schoepf)
%
% Version 3.0 (1992):  Rewrite, including sorting.  Make entries like "4th"
% be treated properly as text.
% 3.1: Bug fixes (and Joerg-Martin Schwarz also convinced me to use \ifcat)
% 3.2: NFSS support was wrong--added \reset@font.  Suppress repetitions of
%      warnings.  Include \@extra@b@citeb hook.
% 3.3: Handle LaTeX2e options. Introduce various customization hooks.
% 3.4: Heuristics to avoid removing \hspace glue before on-line \cite.
%      Make \nocite ignore spaces in list, simplify. Aliases for \citen.
%      Compatability with amsmath (which defines \over).
% 3.5: Replace \reset@font with \selectfont so italics are preserved
%      Include \G@refundefinedtrue.  Fix cite-with-note bug (Lars Engebretsen).
% 3.6: Add nosort option.
% 3.7: Add nomove option; catcode preservation and global \@no@sparg for
%      french.sty; warnings in \nocite.
% 3.8: \citedash hook, fix token look-ahead (Heiko Selber), noadjust, babel.
% 3.9: More babel-compatibility hacks. Punctuation move with \frencspacing.
% 4.0: Combine overcite with cite: [superscript] option.  Also add [nocompress]
%      option and \CiteMoveChars; multibib hooks.
% 4.01 \bf -> \bfseries
% 4.02 Bury undouble action in a separate macro to avoid extra \fi error.
% 5.0  Hyperref and backref compatability! Penalty parameters and [nobreak]. 
%      Letter prefix and suffix sorting! Stop suppressing multiple warnings.
% 5.1  Fix a missing "b@" (disappearing named cites), fix nosort
% 5.2  More robust treatment of non-numbers
% 5.3  Handle sort/compress of compound citation numbers (number by chapter)
%      such as 3.18 or 5-3.  Note that these compounds cannot have prefix or
%      suffix letters (not enough bits in the maximum TeX number).
% 5.4  Only ignore spaces at begin and end of tag (LaTeX ignores at begin)
% 5.5  Improve handling of \frenchspacing. Option rearrangements.
%
% TODO: other sorting, like dictionary or roman numeral
% TODO: create special "final punct" that could be ", and " and likewise
%       a "single punct" that could be " and " 
%
% Send problem reports to asnd@triumf.ca

Test file integrity:  ASCII 32-57, 58-126:  !"#$%&'()*+,-./0123456789
:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~