Debian Codegraph @

texmf-dist/tex/latex/cite/cite.sty

raw
1 % C I T E . S T Y
2 %
3 % version 5.5 (Feb 2015)
4 %
5 % Compressed, sorted lists of on-line or superscript numerical citations.
6 % see also drftcite.sty (And the stub overcite.sty)
7 %
8 % Copyright (C) 1989-2015 by Donald Arseneau
9 % These macros may be freely used, transmitted, reproduced, or modified
10 % provided that this notice is left intact.
11 %
12 % Instructions in cite.pdf and follow \endinput.
13 % ------------------------------------
14 % First, ensure that some catcodes have the expected values
15 \edef\citenum{% temporary def to restore funny codes later
16 \catcode\string`\string ` \the\catcode\string`\`
17 \catcode\string`\string ' \the\catcode\string`\'
18 \catcode\string`\string . \the\catcode\string`\.
19 \catcode\string`\string = \the\catcode\string`\=
20 \catcode\string`\string _ \the\catcode\string`\_
21 \catcode\string`\string : \the\catcode\string`\:}
22 % set codes:
23 \catcode\string`\` 12
24 \catcode`\' 12
25 \catcode`\. 12
26 \catcode`\= 12
27 \catcode`\_ 8 % This is UNusual
28 \catcode`\: 12
29
30 % Prepare for optional variations:
31 % [ verbose, nospace, space, ref, nosort, noadjust, superscript, nomove ],
32 % \citeform,\citeleft,\citeright,\citemid,\citepunct,\citedash
33 %
34 % Set defaults first:
35
36 % [ on the left. Option [ref] does: [Ref. 12, note]
37 \providecommand\citeleft{[}
38
39 % ] on the right:
40 \providecommand\citeright{]}
41
42 % , (comma space) before note
43 \providecommand\citemid{,\penalty\citemidpenalty\ }
44
45 % , (comma thin-space) between entries; [nospace] eliminates the space
46 \providecommand\citepunct{,\penalty\citepunctpenalty%
47 \hskip.13emplus.1emminus.1em\relax}%
48
49 % -- (endash) designating range of numbers:
50 % (using \hbox avoids easy \exhyphenpenalty breaks)
51 \providecommand{\citedash}{\hbox{--}\penalty\citepunctpenalty}
52
53 % Default line-breaking penalties. Use \mathchardef instead of count registers
54 \mathchardef\citeprepenalty=\@highpenalty
55 \mathchardef\citemidpenalty=\@medpenalty
56 \mathchardef\citepunctpenalty=\@m
57
58 % Each number left as-is:
59 \providecommand\citeform{}
60
61 % punctuation characters to move for overcite
62 \providecommand{\CiteMoveChars}{.,:;}
63
64 % font selection for superscript numbers
65 \providecommand\OverciteFont{\fontsize\sf@size\baselineskip\selectfont}
66
67
68 % [verbose] is no-op. Default is to repeat warnings anyway.
69 %\let\oc@verbo\relax
70
71 %----------------------
72 % \citen uses \@nocite to ignore spaces after commas, and write the aux file
73 % \citation. \citen then loops over the citation tags, using \@make@cite@list
74 % to make a sorted list of numbers. Finally, \citen executes \@citelist to
75 % compress ranges of numbers and print the list. \citen can be used by itself
76 % to give citation numbers without the brackets and other formatting; e.g.,
77 % "See also ref.~\citen{junk}."
78 % Make internal version called \@cite@n just in case packages put hooks in
79 % \citen
80 %
81 \DeclareRobustCommand\citen{\@cite@n}
82 \def\@cite@n#1{%
83 \begingroup
84 \let\@safe@activesfalse\@empty
85 \@nocite{#1}% ignores spaces, writes to .aux file, returns #1 in \@no@sparg
86 \@tempcntb\m@ne % \@tempcntb tracks highest number
87 \let\@celt\delimiter % an unexpandable, but identifiable, token
88 \def\@cite@list{}% % empty list to start
89 \let\@citea\@empty % no punctuation preceding first
90 \@for \@citeb:=\@no@sparg\do{\@make@cite@list}% make a sorted list of numbers
91 % After sorted citelist is made, execute it to compress citation ranges.
92 \@tempcnta\m@ne % no previous number
93 \mathchardef\@cite@incr\z@ % no previous sequence
94 \let\@h@ld\@empty % nothing held from list yet
95 \let\@celt\@compress@cite \@cite@list % output number list with compression
96 \@h@ld % output anything held over
97 \endgroup
98 \@restore@auxhandle
99 }
100
101 % For each citation, check if it is defined. If so, then extract plain
102 % value to \@B@citeB (without hyperlink info). Then,
103 % If it is a pure number, add it to cite list
104 % Otherwise, try extracting prefix and suffix characters.
105 %
106 \def\@make@cite@list{%
107 \expandafter\ifx\csname b@\@citeb\@extra@b@citeb
108 \endcsname\relax % undefined: output ? and warning
109 \@citea {\bfseries ?}\let\@citea\citepunct \G@refundefinedtrue
110 \@warning {Citation `\@citeb' on page \thepage\space undefined}%
111 %% always verbose \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}%
112 \else % defined
113 \@cite@nonhyper@sanitize
114 \@addto@cite@list
115 \fi}
116
117 \def\@nonhyper@@link [#1]#2#3#4{#4}
118 \def\@cite@nonhyper@sanitize{\begingroup
119 \let\hyper@@link\@nonhyper@@link
120 \protected@xdef\@B@citeB{\csname b@\@citeb\@extra@b@citeb \endcsname}%
121 \endgroup}
122
123 \def\@cite@out#1{\citeform{\csname #1\endcsname}}
124
125 % Add entry to the list of citations. This default definition sorts pure
126 % numbers as well as numbers with other single-character tags. There
127 % is presently no other definition than this default, but features may
128 % be added later.
129 %
130 \def\@addto@cite@list{%
131 \@cite@posnumtest\@B@citeB
132 {\@addnumto@cite@list\@B@citeB}% a positive number, put in list
133 {\@cite@combo@num}% not a pure positive number, test for combo forms
134 }
135
136 % With this \@cite@combo@num we delve into handling of numbers combined
137 % with non-numeric tags. The specific command name \@cite@combo@num can
138 % serve as a hook for redefinition, perhaps to give simple non-sorting
139 % for anything not a pure number, or to attempt even more complicated
140 % sorting, say dictionary sorting of textual citations. The following
141 % definition leads down the road of sorting mostly-numbers but with
142 % optional single-character prefix and/or suffix.
143
144 \def\@cite@combo@num{\expandafter\@cite@try@combo\@B@citeB\delimiter}
145
146 % First of many stages for sorting numbers with prefix/suffix characters.
147 % Test for a leading token of category letter or other (appropriate for
148 % all combination types).
149 %
150 \def\@cite@try@combo{%
151 \@if@printable@char{\@cite@try@prefix}{\@cite@gobbledump@now}}
152
153 % First token is good, so test for a character prefix before a number.
154 % Process first token, either a first digit or a prefix
155 %
156 \def\@cite@try@prefix#1{% #1 is first character of citation
157 \@cite@posnumtest{#1}% a digit else prefix
158 {\@cite@add@letnumD {\z@}#1}% no prefix character (use zero)
159 {\@cite@add@letnumC {`#1}}% prefix char; use the char code
160 }
161
162 % Examine character after prefix to ensure it is a number. First must
163 % ensure it is a plain character token
164 %
165 \def\@cite@add@letnumC#1{\@if@printable@char%
166 {\@cite@add@letnumD{#1}}% continue with prefix (perhaps zero)
167 {\@cite@gobbledump@now}% else abandon fancy processing and output citation
168 }
169
170 % Save prefix (if any) numerically in \@tempcnta, test next character for being
171 % a digit, then collect main number
172 %
173 \def\@cite@add@letnumD#1#2{% #1 = numeric code for prefix, #2 = next char
174 \@tempcnta=#1\multiply\@tempcnta 16384 %
175 \@cite@posnumtest{#2}% if next char is a digit, continue with number:
176 {\afterassignment\@cite@add@letnumE \advance\@tempcnta #2}%
177 {\@cite@gobbledump@now}% No number so just output citation
178 }
179
180 % Have collected number. Now look for a non-number suffix or separator.
181 %
182 \gdef\@cite@add@letnumE{%
183 \multiply\@tempcnta\@cclvi
184 \@if@printable@char{% a suffix or separator given
185 \@cite@add@letnumF
186 }{% else, maybe nothing remains
187 \ifx\@let@token\delimiter % use number, and remove trailing \delimiter
188 \@citeaddcnta \expandafter\@gobble
189 \else % non-printable char found, so abandon fancy processing
190 \expandafter\@cite@gobbledump@now
191 \fi
192 }}
193
194 % Have everything up to a suffix or separator character. Check
195 % following to see which. Three possibilites are (1) nothing =>
196 % a suffix; (2) number => separator-number; (3) other => garbage.
197 %
198 \def\@cite@add@letnumF#1#2\delimiter{% #1 = suffix/separator #2=rest
199 \advance\@tempcnta`#1\relax
200 \@cite@posnumtest{#2}{\@cite@add@numsepnum{#2}}% handle as num sep num
201 {% else...
202 \ifx\delimiter#2\delimiter % nothing left, so #1 is a suffix
203 \@citeaddcnta
204 \else % some non-number; dump it
205 \@cite@dump@now
206 \fi
207 }}
208
209 % Handle citation as number separator number.
210 % Yes, there is a bug that the list 1.1,1.258,1.515 will be compressed as
211 % 1.1-1.515; so sue me.
212
213 \def\@cite@add@numsepnum#1{% #1 = last number
214 \ifnum\@tempcnta<262144 % OK numeric range
215 \multiply\@tempcnta 4096
216 \advance\@tempcnta #1 % num,sep,num have maximum numbers: 1023, 255, 4095
217 \@citeaddcnta
218 \else % out of range, treat as raw string
219 \@cite@dump@now
220 \fi}
221
222 % This is our bail-out when the citation cannot be processed as
223 % [prefix]number[suffix] or number[sep]number: it outputs the citation
224 % immediately (unsorted) and consumes tokens to the \delimiter tag used
225 % as an end-marker
226 %
227 \def\@cite@gobbledump@now#1\delimiter{\@cite@dump@now}%
228
229 \def\@cite@dump@now{%
230 \@citea \@cite@out{b@\@citeb\@extra@b@citeb}\let\@citea\citepunct}
231
232 % add an entry to the sorted list, using its sort-number \@tempcnta, and
233 % also saving the plain-text value \@B@citeB as well as the csname
234 % b@\@citeb\@extra@b@citeb. (The \@B@citeB is actually not used, unless
235 % somebody extends the definitions.)
236 \def\@citeaddcnta{%
237 \ifnum \@tempcnta>\@tempcntb % new highest, add to end (efficiently)
238 \edef\@cite@list{\@cite@list
239 \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}%
240 \@tempcntb\@tempcnta
241 \else % other sortable value: insert appropriately
242 \edef\@cite@list{\expandafter\@sort@celt\@cite@list \@gobble.\@gobble.}%
243 \fi
244 }
245
246 % add pure numeric entry to cite list, with sorting
247 \def\@addnumto@cite@list#1{%
248 \@tempcnta#1\relax
249 \multiply\@tempcnta\@cclvi
250 \@citeaddcnta}
251
252 % \@sort@celt inserts number (\@tempcnta) into list of \@celt{num}{text}{tag}
253 % (#1{#2}{#3}{#4})
254 % \@celt must not be expandable, and the arguments must not be fragile.
255 % List should end with four vanishing tokens.
256 %
257 \def\@sort@celt#1#2#3#4{\ifx \@celt #1% parameters are \@celt{num}{text}{tag}
258 \ifnum #2<\@tempcnta % number goes later in list
259 \@celt{#2}{#3}{#4}%
260 \expandafter\expandafter\expandafter\@sort@celt % continue
261 \else % number goes here
262 \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}%
263 \@celt{#2}{#3}{#4}% stop comparing
264 \fi\fi}
265
266 % Check if each number follows previous and can be put in a range.
267 % Since there are suffix characters allowed, there are two kinds of
268 % ranges: ranges of consecutive pure numbers with no (or same)
269 % suffix, or ranges of the same number with consecutive suffix
270 % characters.
271 %
272 \def\@compress@cite#1#2#3{%% This is executed for each number
273 \ifnum\@cite@incr=\z@ % no consecutives pending. Try both types of sequence
274 \advance\@tempcnta\@cclvi % Now \@tempcnta has incremented number
275 \ifnum #1=\@tempcnta % Start a sequence of consecutive numbers
276 \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}%
277 \mathchardef\@cite@incr=\@cclvi
278 \else % next try increment of suffix
279 \advance\@tempcnta-\@cclv % Now \@tempcnta has incremented suffix
280 \ifnum #1=\@tempcnta % Start a sequence of suffix increments
281 \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}%
282 \mathchardef\@cite@incr=\@ne
283 \else % it is no type of sequence -- emit number (nothing is held)
284 \@citea \@cite@out{#3}%
285 \fi
286 \fi
287 \else % a sequence is running
288 \advance\@tempcnta\@cite@incr % Now \@tempcnta is next in sequence
289 \ifnum #1=\@tempcnta % Number follows previous--hold on to it
290 \def\@h@ld{\citedash \@cite@out{#3}}%
291 \else % non-successor -- dump what's held and do this one
292 \@h@ld \@citea \@cite@out{#3}%
293 \let\@h@ld\@empty
294 \mathchardef\@cite@incr=\z@
295 \fi
296 \fi
297 \@tempcnta#1\let\@citea\citepunct
298 }
299
300 % Ordinary on-line \cite command
301
302 \DeclareRobustCommand{\cite}{%
303 \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}
304
305 % Do \cite command on line.
306 %
307 \def\@citex[#1]#2{\@cite{\@cite@n{#2}}{#1}}
308
309 \def\@cite#1#2{\leavevmode \cite@adjust
310 \citeleft{#1\if@tempswa\@safe@activesfalse\citemid{#2}\fi
311 \spacefactor\@m % punctuation in note doesn't affect outside
312 }\citeright
313 \@restore@auxhandle}
314
315 % Put a penalty before the citation, and adjust the spacing: if no space
316 % already or if there is extra space due to some punctuation, then change
317 % to one inter-word space.
318 %
319 \def\cite@adjust{\begingroup%
320 \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip
321 \ifnum\lastpenalty=\z@ \penalty\citeprepenalty \fi
322 \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag
323 \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi
324 \endgroup}
325
326 \edef\@zero@skip{\the\z@skip}
327
328 % \nocite: This is changed to ignore *ALL* spaces and be robust. The
329 % parameter list, with spaces removed, is `returned' in \@no@sparg, which
330 % is used by \@cite@n (\citen).
331 %
332 \DeclareRobustCommand\nocite[1]{%
333 \@bsphack \@nocite{#1}%
334 \@for \@citeb:=\@no@sparg\do{\@ifundefined{b@\@citeb\@extra@b@citeb}%
335 {\G@refundefinedtrue\@warning{Citation `\@citeb' undefined}%
336 %%\oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}
337 }{}}%
338 \@esphack}
339
340 \def\@nocite#1{\begingroup\let\protect\string% normalize active chars
341 \xdef\@no@sparg{\expandafter\@cite@ignsp#1,\: ,\:}% remove spaces
342 \if@filesw \immediate\write\@newciteauxhandle % =\@auxout, except with multibib
343 {\string\citation {\@no@sparg}}\fi
344 \endgroup}
345
346 % remove spaces before and after commas. One level of braces is also
347 % stripped, so an item {a,b} is changed to two a and b.
348 %
349 \def\@cite@ignsp#1 ,#2{\ifx\:#2\@empty
350 \expandafter\@cite@ignsp@\romannumeral-`\:\else
351 \expandafter\@cite@ignsp \fi #1,#2}
352 \def\@cite@ignsp@#1,#2{#1\ifx\:#2\@empty\expandafter\@gobblethree
353 \else,\expandafter\@cite@ignsp@\fi #2}
354
355 \long\def\@gobblethree #1#2#3{}
356
357 % \@if@fillglue{glue}{true}{false}
358 \begingroup
359 \catcode`F=12 \catcode`I=12\catcode`L=12
360 \lowercase{\endgroup
361 \def\@if@fillglue#1{%
362 \begingroup \skip@#1\relax
363 \expandafter\endgroup\expandafter
364 \@is@fil@ \the\skip@ \relax\@firstoftwo FIL\relax\@secondoftwo\@nil}
365 \def\@is@fil@ #1FIL#2\relax#3#4\@nil{#3}
366 }
367
368 % Test if next token is a char of "printable" categories other or letter or
369 % active. Syntax:
370 % \@if@printable@char {do if printable}{do if not printable}<char>
371 %
372 \def\@if@printable@char#1#2{%
373 \def\reserved@a{#1}%
374 \def\reserved@b{#2}%
375 \futurelet\@let@token\@test@print@char
376 }
377
378 % Note side-effect of redefining \reserved@a and \reserved@b
379 \def\@test@print@char{%
380 \ifnum
381 \ifcat\noexpand\@let@token A1\fi
382 \ifcat\noexpand\@let@token 11\fi
383 \ifcat\noexpand\@let@token \noexpand~1\fi%
384 0>\z@
385 \expandafter\reserved@a \else
386 \expandafter\reserved@b \fi
387 }
388
389 % Test for a pure positive number: {possible number}{true}{false}
390 \def\@cite@posnumtest#1{%
391 \ifcat _\ifnum\z@<0#1_\else A\fi
392 \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi
393 }
394
395 \let\nocitecount\relax % in case \nocitecount was used for drftcite
396
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 % option processing
399 \def\oc@movep{YY}% default Yes move
400 %
401 \DeclareOption{verbose}{}% Unused now. Was \def\oc@verbo#1#2#3#4{}
402 \DeclareOption{nospace}{\def\citepunct{,\penalty\citepunctpenalty}}
403 \DeclareOption{space}{\def\citepunct{,\penalty\citepunctpenalty\ }}
404 \DeclareOption{nobreak}{% no line-breaks
405 \mathchardef\citeprepenalty=\@M
406 \mathchardef\citemidpenalty=\@M
407 \mathchardef\citepunctpenalty=\@M
408 }
409 \DeclareOption{ref}{\def\citeleft{[Ref.\penalty\@M\ }}
410 % To disable sorting [nosort], the redefinition depends on whether [nocompress]
411 % was also selected, so just set a flag first.
412 \DeclareOption{nosort}{\let\@citeaddcnta\@empty}
413 \DeclareOption{sort}{}% default!
414 % Likewise set flag for [nocompress]
415 \DeclareOption{nocompress}{\let\@compress@cite\@empty}
416 \DeclareOption{compress}{}% default
417 \DeclareOption{nomove}{\def\oc@movep{no}}% Flag for later definition
418 \DeclareOption{move}{\def\oc@movep{YY}}% default
419 \DeclareOption{super}{\ExecuteOptions{superscript}}
420 \DeclareOption{superscript}{\let\@citess\cite}% Just a flag redefined below
421 \DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces
422 \DeclareOption{adjust}{}% adjust space before [ ]
423 \DeclareOption{biblabel}{\let\@biblabel\def}% see below
424 \ProvidesPackage{cite}[2015/02/27 \space v 5.5]
425 \ProcessOptions
426
427 \ifx\@biblabel\def % [biblabel] option
428 \ifx\@citess\cite % [superscript] option
429 \def\@biblabel#1{\@citess{#1}\kern-\labelsep\,}
430 \else % normal
431 \def\@biblabel#1{\citeleft{#1}\citeright}
432 \fi
433 \fi
434
435 % Process [superscript] option, and [nomove].
436
437 \ifx\@citess\cite
438
439 % Superscript cite, \cite chooses superscript or on-line-with-note
440 %
441 \DeclareRobustCommand{\cite}{%
442 \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citew}}
443
444 % Superscript cite, with no optional note. Check for punctuation first.
445 \def\@citew#1{\begingroup \leavevmode
446 \@if@fillglue \lastskip \relax \unskip
447 \def\@tempa{\@tempcnta\spacefactor
448 \/% this allows the last word to be hyphenated, and it looks better.
449 \@citess{\@cite@n{#1}}\spacefactor\@tempcnta
450 \endgroup \@restore@auxhandle}%
451 \oc@movep\relax}% check for following punctuation (depending on options)
452
453 % \@citess defines the formatting with superscripts and no brackets.
454 % HOWEVER, trailing punctuation has already been moved over. The
455 % format for cites with note is given by \@cite. Redefine \@cite and/
456 % or \@citex to get different appearance. I don't use \textsuperscript
457 % because it is defined BADLY in compatibility mode.
458
459 \def\@citess#1{\mbox{$\m@th^{\hbox{\OverciteFont{#1}}}$}}
460
461 \if \oc@movep % Move citation past trailing punctuation; [move] is default
462
463 \def\oc@movep#1{\futurelet\@tempb\@citey}
464 %
465 \def\@citey{\let\@tempc\@tempa
466 % Watch for double periods and suppress them
467 \ifx\@tempb.\ifnum\spacefactor<\sfcode`.\else
468 \@citeundouble
469 \fi\fi
470 % Move other punctuation
471 \expandafter\@citepc\CiteMoveChars\delimiter
472 \@tempc}%
473
474 % This is in a separate macro in case the next "character" (token)
475 % is \if or \fi, etc.
476 \def\@citeundouble{% Suppress doubling of periods
477 \let\@tempb\relax \let\@tempc\oc@movep
478 }
479
480 \def\@citepc#1{%
481 \ifx\@tempb#1\@empty #1\let\@tempc\oc@movep \fi
482 \ifx\delimiter#1\else \expandafter\@citepc\fi}
483
484 % Set detectable sfcodes when \frenchspacing
485 \mathchardef\cite@mi1001 %
486 \g@addto@macro\frenchspacing
487 {\sfcode`\.\cite@mi \sfcode`\?\cite@mi \sfcode`\!\cite@mi }%
488 \AtBeginDocument {%
489 \ifnum\sfcode`\.<1002 \frenchspacing \let\normalsfcodes\frenchspacing \fi
490 }% performed after \normalsfcodes defined
491
492 \else % [nomove] option:
493
494 \def\oc@movep{\@tempa}
495 \let\@citey\relax
496
497 \fi % end of move/nomove options
498 %
499 \fi % end [superscript] option processing
500 %
501 % make redefinitions to handle [nosort] [nocompress] and their combination
502 \ifx\@compress@cite\@empty
503 \ifx\@citeaddcnta\@empty
504 % [nosort,nocompress] -- short-circuit much processing
505 \def\@addto@cite@list{\@cite@dump@now}
506 \else
507 % [sort,nocompress]
508 \def\@compress@cite#1#2#3{% % This is executed for each number
509 \@h@ld \@citea \@cite@out{#3}%
510 \let\@h@ld\@empty \let\@citea\citepunct
511 }
512 \fi
513 \else %
514 \ifx\@citeaddcnta\@empty % [nosort,compress]
515 % nosort: always add to end of list, but still calculate
516 % sort-order number (\@tempcnta) because it may be used for
517 % collapsing consecutive numbers.
518 \def\@citeaddcnta{%
519 \edef\@cite@list{\@cite@list
520 \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}%
521 }
522 \fi
523 \fi
524
525 % Compatability with chapterbib (see use of \@extra@b@citeb above and in chapterbib)
526 \@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}
527
528 % Compatability with multibib (see use of \@newciteauxhandle) (Yes, this is
529 % overly messy, but I asked for it... I can't have multibib putting junk after
530 % the cite command because it hides following punctuation, but then I have
531 % to restore the ordinary meaning of \@newciteauxhandle = \@auxout.)
532 \providecommand\@newciteauxhandle{\@auxout}
533 \AtBeginDocument{\@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}}
534 \def\@restore@auxhandle{\def\@newciteauxhandle{\@auxout}}
535
536 % compatability with backref: prevent it from redefining \@citex
537 % in the wrong way (ignoring \@citew and \citen. I install hook in
538 % \@nocite so it applies to \cite, \citen, and \nocite.
539 %
540 \AtBeginDocument{\@ifundefined{Hy@backout}{}{%
541 \@ifundefined{BRorg@citex}{}{\global\let\@citex\BRorg@citex}%
542 \global\let\BR@citex\@citex
543 \global\let\@citeorg@nocite\@nocite % use my own hook -> into \@nocite
544 \gdef\@nocite#1{\@citeorg@nocite{#1}\Hy@backout{#1}}%
545 }}
546
547 % compatability with babel: Prevent it from redefining \@citex
548 \@ifundefined{@safe@activesfalse}{\let\@safe@activesfalse\relax}{}
549 \@ifundefined{bbl@cite@choice}{}{\@ifundefined{org@@citex}{}%
550 {\let\org@@citex\@citex}}% Prevent stomping by babel
551
552 \citenum % execute restore-catcodes
553
554 % Aliases:
555 \def\citenum{\citen}
556 \def\citeonline{\citen}
557
558 \endinput
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
560
561
562 CITE.STY
563
564 Modify LaTeX's normal citation mechanism for improved handling of numeric
565 citations, behaving as follows:
566
567 o Put a comma and a small space between each citation number, allowing
568 line breaks with penalty.
569
570 o Compress lists of three or more consecutive numbers, or similar, to a
571 range which can be split, with difficulty, after the dash.
572
573 o Sort citations into ascending order.
574
575 o Sortable and compressible citations are numeric like [5-8]; or numbers
576 with prefix and/or suffix characters like [18a-18c,19] or [A2,Q1,Q3-Q5];
577 or two numbers with separator like [1.9-1.12,2.2].
578
579 o Allow, but discourage, line breaks within the group of citations (after
580 dashes, and after punctuation).
581
582 o Adjust spacing before citation.
583
584 o All breaks can be forbidden with the [nobreak] package option.
585
586 o With package option [superscript] (or [super] for short), display citations
587 as superscripts (unless they have optional notes, causing them to be printed
588 on-line with brackets). Superscripted citations use THE SAME INPUT FORMAT
589 as ordinary citations; this style will ignore spaces before the \cite command
590 and move trailing punctuation before the superscript citation. Doubling of
591 periods (.., ?., !.) is checked for and suppressed.
592
593 o Define \citen to get just the numbers without the brackets or superscript
594 and extra formatting. Aliases are \citenum and \citeonline.
595
596 There are several package options for \usepackage{cite}.
597
598 [superscript] use superscrpts for cites without optional notes
599 [super] alias for [superscript] (like natbib)
600 [nospace] eliminates the spaces after commas in the number list
601 [space] uses a full inter-word space after the commas
602 [nobreak] eliminate all line-breaks
603 [nosort] prevents sorting of the numbers (default is to sort, and the...
604 [sort] option is provided for completeness).
605 [nomove] prevents moving the superscript cite after punctuation.
606 [move] is the default
607 [noadjust] disables `smart' handling of space before a cite
608 [adjust] is the default
609 [nocompress] inhibit compression of consecutive numbers into ranges
610 [compress] is the default
611 [ref] uses the format "[Ref.~12, given note]" (useful with [super])
612 [biblabel] define the bibliography label to match \cite
613
614 If your citations are not numeric, then you should probably not use
615 cite.sty, but if you must, then at least use the [nosort,nocompress]
616 options.
617
618 See more detailed instructions in cite.pdf (cite.ltx).
619
620
621 % Version 1991: Ignore spaces after commas in the parameter list. Move most of
622 % \citen into \@cmpresscites for speed. Give the proper \spacefactor afterwards.
623 % Version 1992: make \citepunct hold the punctuation between numbers (for ease
624 % of changing). Add \/ to allow hyphenation of previous word, and look better
625 % in italics.
626 % 1992a: Make it work with NFSS. (Thank you C. Hamlin and Rainer Schoepf)
627 %
628 % Version 3.0 (1992): Rewrite, including sorting. Make entries like "4th"
629 % be treated properly as text.
630 % 3.1: Bug fixes (and Joerg-Martin Schwarz also convinced me to use \ifcat)
631 % 3.2: NFSS support was wrong--added \reset@font. Suppress repetitions of
632 % warnings. Include \@extra@b@citeb hook.
633 % 3.3: Handle LaTeX2e options. Introduce various customization hooks.
634 % 3.4: Heuristics to avoid removing \hspace glue before on-line \cite.
635 % Make \nocite ignore spaces in list, simplify. Aliases for \citen.
636 % Compatability with amsmath (which defines \over).
637 % 3.5: Replace \reset@font with \selectfont so italics are preserved
638 % Include \G@refundefinedtrue. Fix cite-with-note bug (Lars Engebretsen).
639 % 3.6: Add nosort option.
640 % 3.7: Add nomove option; catcode preservation and global \@no@sparg for
641 % french.sty; warnings in \nocite.
642 % 3.8: \citedash hook, fix token look-ahead (Heiko Selber), noadjust, babel.
643 % 3.9: More babel-compatibility hacks. Punctuation move with \frencspacing.
644 % 4.0: Combine overcite with cite: [superscript] option. Also add [nocompress]
645 % option and \CiteMoveChars; multibib hooks.
646 % 4.01 \bf -> \bfseries
647 % 4.02 Bury undouble action in a separate macro to avoid extra \fi error.
648 % 5.0 Hyperref and backref compatability! Penalty parameters and [nobreak].
649 % Letter prefix and suffix sorting! Stop suppressing multiple warnings.
650 % 5.1 Fix a missing "b@" (disappearing named cites), fix nosort
651 % 5.2 More robust treatment of non-numbers
652 % 5.3 Handle sort/compress of compound citation numbers (number by chapter)
653 % such as 3.18 or 5-3. Note that these compounds cannot have prefix or
654 % suffix letters (not enough bits in the maximum TeX number).
655 % 5.4 Only ignore spaces at begin and end of tag (LaTeX ignores at begin)
656 % 5.5 Improve handling of \frenchspacing. Option rearrangements.
657 %
658 % TODO: other sorting, like dictionary or roman numeral
659 % TODO: create special "final punct" that could be ", and " and likewise
660 % a "single punct" that could be " and "
661 %
662 % Send problem reports to [email protected]
663
664 Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789
665 :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~