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
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
% C I T E . S T Y
%
% version 5.3 (Sep 2010)
%
% Compressed, sorted lists of on-line or superscript numerical citations.
% see also drftcite.sty (And the stub overcite.sty)
%
% Copyright (C) 1989-2010 by Donald Arseneau
% These macros may be freely used, transmitted, reproduced, or modified
% provided that this notice is left intact.
%
% Instructions follow \endinput.
% ------------------------------------
% First, ensure that some catcodes have the expected values
\edef\citenum{% to restore funny codes
\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`\` 12
\catcode`\' 12
\catcode`\= 12
\catcode`\_ 8
\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}
% Do not repeat warnings. [verbose] reverses
\let\oc@verbo\relax
% Default is to move punctuation:
\def\oc@movep#1{\futurelet\@tempb\@citey}
%----------------------
% \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}%
%% \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}% ???
\else % defined % remove previous line to repeat warnings
\@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
}
% 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 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) noting =>
% 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
}
% Make \cite choose superscript or normal
\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}
% 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)
% Move trailing punctuation before the citation:
%
\def\@citey{\let\@tempc\@tempa
% Watch for double periods and suppress them
\ifx\@tempb.\ifnum\spacefactor<\@bigSfactor\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}
% Replacement for \@cite which defines the formatting normally done
% around the citation list. This uses superscripts with 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}}}$}}
% \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\@ignsp#1 \: }\endgroup% and remove ALL spaces
\if@filesw \immediate\write\@newciteauxhandle % =\@auxout, except with multibib
{\string\citation {\@no@sparg}}\fi
}
% for ignoring *ALL* spaces in the input. This presumes there are no
% \outer tokens and no \if-\fi constructs in the parameter. Spaces inside
% braces are retained.
%
\def\@ignsp#1 {\ifx\:#1\@empty\else #1\expandafter\@ignsp\fi}
% \@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
\DeclareOption{verbose}{\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{\@tempa}\let\@citey\oc@movep}
\DeclareOption{move}{}% default
\DeclareOption{super}{\ExecuteOptions{superscript}}
\DeclareOption{superscript}{%
\DeclareRobustCommand{\cite}{%
\@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citew}}
}
\DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces
\DeclareOption{adjust}{}% adjust space before [ ]
\DeclareOption{biblabel}{\def\@biblabel#1{\@citess{#1}\kern-\labelsep\,}}
\ProvidesPackage{cite}[2010/09/10 \space v 5.3]
\ProcessOptions
\ifx\@citey\oc@movep\else % we are moving punctuation; must ensure sfcodes
\mathchardef\@bigSfactor3000
\expandafter\def\expandafter\frenchspacing\expandafter{\frenchspacing
\mathchardef\@bigSfactor1001
\sfcode`\.\@bigSfactor \sfcode`\?\@bigSfactor \sfcode`\!\@bigSfactor }%
\ifnum\sfcode`\.=\@m \frenchspacing \fi
\fi
% 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 ooold LaTeX
\@ifundefined{G@refundefinedtrue}{\let\G@refundefinedtrue\relax}{}
% 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. The option
[nospace] removes that space, and the option [space] replaces it with
an ordinary inter-word space.
o Compress lists of three or more consecutive numbers to one number range
which can be split, with difficulty, after the dash. All numbers should
be greater than zero. E.g., if you used to get the (nonsense) list
[7,5,6,?,4,9,8,Einstein,6], then this style will give [?,Einstein,4-6,6-9].
Compression of ranges is disabled by the [nocompress] package option.
o Sort citations into ascending order (this is the default, but may also
be declared with the package option [sort]). The [nosort] package option
turns off sorting. Sortable citations must fit one of these forms:
1. <number>
2. <optional-char><number><optional-char>
3. <number><separator-char><number>
Forms 1 and 2 are really the same, and they mix well, but form 3 is
separate and if used simultaneously with form 1 the citations become,
ummm, mixed. Non-sortable forms (those not listed) are printed before
all sortable forms. Here <number> means a positive integer (natural
number) less than some limit (different for each form), <optional-char>
is a single printable character (or nothing), and <separator-char> is also
a single printable character.
o Sorting of citations with prefix and/or suffix characters is done so so
different prefixes are grouped separately, and suffixes form sub-lists
for the same number. Compression knows about suffixes, so you can get
lists like [18a-18c,19] or [A2,Q1,Q3-Q5].
o Allow, but discourage, line breaks within the group of citations (after
dashes, and after punctuation). Penalties are \citepunctpenalty and
\citemidpenalty.
o Put a high-penalty breakpoint (value \citeprepenalty) before the citation
(unless there is a different penalty specified there). Also, adjust the
spacing: if there is no space or if there is extra space due to some
punctuation, then change to one inter-word space. E.g.,
A space will be inserted here\cite{Larry,Curly,Moe}.
o All breaks can be forbidden with the [nobreak] package option. They can
be adjusted independently by setting the parameters \citeprepenalty,
\citemidpenalty, and \citepunctpenalty. Use \mathchardef to change these
penalty values! E.g., \mathchardef\citeprepenalty=9999 (Yes, that is
obscure but I don't want to use up counters or to pretend they are counters.)
o With package option [superscript] (or [super] for short), display citation
numbers as superscripts (unless they have optional notes, causing them to
be printed on-line with brackets). Superscripted citations follow these
additional rules:
-> Superscript citations use THE SAME INPUT FORMAT as ordinary citations; this
style will ignore spaces before the citation, and move trailing punctuation
before the superscript citation. For example, "information \cite{source};"
ignores the space before \cite and puts the semicolon before the number,
just as if you had typed "information;$^{12}$". You may switch off movement
with the [nomove] package option (only relevant with [superscript]).
-> The punctuation characters that will migrate before the superscript are
listed in the macro \CiteMoveChars, which you can redefine. The default
set of characters is ".,;:"; Perhaps ! and ? should be included too, but
they weren't listed in the APS style manual I looked at, and I agree with
that design choice because they put too much visual separation between the
cite and what it applies to. Feel free to redefine \CiteMoveChars. Quotes
were listed as coming before the cite notation, but they should be typed
before the \cite command in any case because both on-line and superscript
cites come after what is quoted (when citing a quotation). This gives one
difficulty -- punctuation following quotes won't migrate inside the
quotation: e.g., "``Transition State Theory''\cite{Eyring}." gives out
``Transition State Theory''.$^8$, but you may want the period inside the
quotes, thus: ``Transition State Theory.''$^8$.
-> Doubling of periods (.., ?., !.) is checked for and suppressed. The spacing
after the citation is set according to the final punctuation mark moved.
There is a problem with double periods after a capitalized abbreviation
or directly after \@ : Both of "N.A.S.A. \cite{space}." and "et al.\@
\cite{many}." will give doubled periods. These can be fixed as follows:
"N.S.A\@. \cite{space}." and "et al.\ \cite{many}.". The NSA example
gives the wrong spacing when there is no citation. Sorry. Use "\ " after
abbreviations like et al. to get the right spacing within a sentence whether
or not a citation follows.
-> Remember, these rules regarding punctuation only apply when the [super]
or [superscript] option was given (or overcite.sty used) and the [nomove]
option was NOT given.
o Define \citen to get just the numbers without the brackets or superscript
and extra formatting. Aliases are \citenum and \citeonline for easy
conversion to other citation packages.
o All of \nocite, \cite, and \citen ignore spaces in the input tags.
Although each \cite command sorts its numbers, better compression into
ranges can usually be achieved by carefully selecting the order of the
\bibitem entries or the order of initial citations when using BibTeX.
Having the entries pre-sorted will also save processing time, especially
for long lists of numbers.
Customization:
~~~~~~~~~~~~~~
There are several options for \usepackage{cite}, some already mentioned.
[superscript] use superscrpts for cites without optional notes
[super] alias for [superscript] (like natbib)
[verbose] UNUSED NOW! (do repeat duplicate warnings)
[ref] uses the format "[Ref.~12, given note]" (useful with
the superscript option)
[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
[biblabel] define the bibliography label as a superscript
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.
There are several commands that you may redefine (using \renewcommand
or \def) to change the formatting of citation lists:
command function default
---------- ----------------------- ----------------------------
\citeform reformats each number nothing
\citepunct printed between numbers comma + penalty + thin space
\citeleft left delimiter of list [
\citeright right delimeter of list ]
\citemid printed before note comma + penalty + space
\citedash used in a compressed range endash + penalty
\CiteMoveChars charcters that move .,:;
\OverciteFont font sel. for superscripts \fontsize{\sf@size}...
The left/mid/right commands don't affect the formatting of superscript
citations. You may use \renewcommand to change any of these. Remember,
these commands are extensions made by this package; they are not regular
LaTeX. Some examples of changes:
1: \renewcommand\citeform[1]{\romannumeral 0#1}} % roman numerals i,vi
2: \renewcommand\citeform[1]{(#1)} % parenthesized numbers (1)-(5),(9)
3: \renewcommand\citeform{\thechapter.} % by chapter: ^{2.18-2.21}
4: \renewcommand\citepunct{,} % no space and no breaks at commas
5: \renewcommand\citemid{; } % semicolon before optional note
6: \renewcommand\citeleft{(} % parentheses around list with note
\renewcommand\citeright{)} % parentheses around list with note
The appearance of the whole citation list is governed by \@cite, (for full-
sized cites) and \@citess (for superscripts). For more extensive changes
to the formatting, redefine these. For example, to get brackets around the
list of superscript numbers you can do:
\def\@citess#1{\textsuperscript{[#1]}}
after \makeatletter.
Related Note: The superscript option does not affect the numbering format
of the bibliography; the "[12]" style is still the default. To get
superscripts in the bibliography (at any time) you can define
\renewcommand\@biblabel[1]{\textsuperscript{#1}}
Aw, OK, for your convenience, there is the [biblabel] package option that
just performs this definition (sort of).
Line breaking can be turned off using the [nobreak] option. It can be
controlled more precisely by changing three numeric values, assigned
with \mathchardef, for controlling the line-break penalties:
\citeprepenalty penalty before cite default \@highpenalty
\citemidpenalty penalty used in \citemid default \@medpenalty
\citepunctpenalty penalty used in \citepunct default 1000
(Use \mathchardef assignments like \mathchardef\citemidpenalty=900.
These were chosen so as to not waste registers.) Alternatively, the
commands \citemid, \citedash, and \citepunct can be redefined to use
different penalty parameters, or none at all.
% 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).
%
% 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{|}~
|