initial setup of thesis repository
[cluster_expansion_thesis.git] / Stylefiles / CITE_1.STY
blob35777efc808a2905ba8d2357f7d635a43b4d46c2
1 %     C I T E . S T Y
3 %     version 3.8  (Apr 1999)
5 %     Compressed, sorted lists of numerical citations: [11-16]
6 %     see also OVERCITE.STY and DRFTCITE.STY
8 %     Copyright (C) 1989-1999 by Donald Arseneau
9 %     These macros may be freely transmitted, reproduced, or modified
10 %     provided that this notice is left intact.
12 %     Instructions follow \endinput.
13 %  ------------------------------------
14 % First, ensure that some catcodes have the expected values
15 \edef\citenum{% to restore funny codes
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`\`12
22 \catcode`\'12
23 \catcode`\=12
24 \catcode`\_8
25 \catcode`\:12
27 %   Handle optional variations:  [verbose,nospace,space,nosort,noadjust],
28 %   \citeform,\citeleft,\citeright,\citemid,\citepunct,\citedash
30 %   Set defaults:
32 %   [ on the left.
33 \@ifundefined{citeleft}{\let\citeleft=[}{}
35 %   ] on the right:
36 \@ifundefined{citeright}{\let\citeright=]}{}
38 %   , (comma space) before note
39 \@ifundefined{citemid}{\def\citemid{,\penalty\@medpenalty\ }}{}
41 %   , (comma thin-space) between entries; [nospace] eliminates the space
42 \@ifundefined{citepunct}{
43    \def\citepunct{,\penalty\@m\hskip.13emplus.1emminus.1em}%
44  }{}
46 %   -- (endash) designating range of numbers:
47 % (using \hbox avoids easy \exhyphenpenalty breaks)
48 \@ifundefined{citedash}{\def\citedash{\hbox{--}\penalty\@m }}{}
50 %   Each number left as-is:
51 \@ifundefined{citeform}{\def\citeform{}}{}
53 %   Do not repeat warnings.  [verbose] reverses
54 \let\oc@verbo\relax
56 \@ifundefined{DeclareOption}{}%
57 { \toks@={\def\oc@verbo#1#2#3#4{}}
58   \DeclareOption{verbose}{\the\toks@}
59   \DeclareOption{nospace}{\def\citepunct{,\penalty\@m}}
60   \DeclareOption{space}{\def\citepunct{,\penalty\@highpenalty\ }}
61   \DeclareOption{nosort}{\def\@addto@cite@list
62    {\edef\@cite@list{\@cite@list \@celt{\@B@citeB}}}}
63   \DeclareOption{sort}{\let\@cite@list\relax}% default!
64   \DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces
65   \DeclareOption{adjust}{\let\cite@adjust\relax}% adjust space before [ ]
66   \ProvidesPackage{cite_1}[1999/04/23 \space  v 3.8]
67   \ProcessOptions }
69 % changed the provides package option!!! to my file cite_1
72 %----------------------
73 % \citen uses \@nocite to ignore spaces after commas, and write the aux file
74 % \citation. \citen then loops over the citation tags, using \@make@cite@list
75 % to make a sorted list of numbers.  Finally, \citen executes \@citelist to
76 % compress ranges of numbers and print the list. \citen can be used by itself
77 % to give citation numbers without the brackets and other formatting; e.g.,
78 % "See also ref.~\citen{junk}."
80 \edef\citen{\noexpand\protect \expandafter\noexpand\csname citen \endcsname}
82 \@namedef{citen }#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\@h@ld\relax   % nothing held from list yet
88 \let\@citea\@empty % no punctuation preceding first
89 \let\@celt\delimiter % an unexpandable, but identifiable, token
90 \def\@cite@list{}% % empty list to start
91 \@for \@citeb:=\@no@sparg\do{\@make@cite@list}% make a sorted list of numbers
92 % After sorted citelist is made, execute it to compress citation ranges.
93 \@tempcnta\m@ne    % no previous number
94 \let\@celt\@compress@cite \@cite@list % output number list with compression
95 \@h@ld % output anything held over
96 \endgroup}
98 % For each citation, check if it is defined and if it is a number.
99 % if a number: insert it in the sorted \@cite@list
100 % otherwise: output it immediately.
102 \def\@make@cite@list{%
103  \expandafter\let \expandafter\@B@citeB
104           \csname b@\@citeb\@extra@b@citeb \endcsname
105  \ifx\@B@citeB\relax % undefined: output ? and warning
106     \@citea {\bf{?}}\let\@citea\citepunct \G@refundefinedtrue
107     \@warning {Citation `\@citeb' on page \thepage\space undefined}%
108     \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}%
109  \else %  defined               % remove previous line to repeat warnings
110     \ifcat _\ifnum\z@<0\@B@citeB _\else A\fi % a positive number, put in list
111        \@addto@cite@list
112     \else % citation is not a number, output immediately
113        \@citea \citeform{\@B@citeB}%
114        \let\@citea\citepunct
115  \fi\fi}
117 % Regular definition for adding entry to cite list, with sorting
119 \@ifundefined{@addto@cite@list}{% sort option either declared or defaulted
120   \def\@addto@cite@list{\@tempcnta\@B@citeB \relax
121      \ifnum \@tempcnta>\@tempcntb % new highest, add to end (efficiently)
122         \edef\@cite@list{\@cite@list \@celt{\@B@citeB}}%
123         \@tempcntb\@tempcnta
124      \else % arbitrary number: insert appropriately
125         \edef\@cite@list{\expandafter\@sort@celt \@cite@list \@gobble @}%
126      \fi}
128 % \@sort@celt inserts number (\@tempcnta) into list of \@celt{num} (#1{#2})
129 % \@celt must not be expandable; list should end with two vanishing tokens.
131   \def\@sort@celt#1#2{\ifx \@celt #1% parameters are \@celt {num}
132        \ifnum #2<\@tempcnta % number goes later in list
133           \@celt{#2}%
134           \expandafter\expandafter\expandafter\@sort@celt % continue
135        \else % number goes here
136           \@celt{\number\@tempcnta}\@celt{#2}% stop comparing
137     \fi\fi}
138 }% end sort option definitions
139 {}% nosort definition is done in options processing
141 % Check if each number follows previous and can be put in a range
143 \def\@compress@cite#1{%  % This is executed for each number
144   \advance\@tempcnta\@ne % Now \@tempcnta is one more than the previous number
145   \ifnum #1=\@tempcnta   % Number follows previous--hold on to it
146      \ifx\@h@ld\relax    % first pair of successives
147         \edef\@h@ld{\@citea \noexpand\citeform{#1}}%
148      \else               % compressible list of successives
149         \def\@h@ld{\citedash \citeform{#1}}%
150      \fi
151   \else   %  non-successor -- dump what's held and do this one
152      \@h@ld \@citea \citeform{#1}\let\@h@ld\relax
153   \fi \@tempcnta#1\let\@citea\citepunct
156 \edef\cite{\noexpand\protect\expandafter\noexpand\csname cite \endcsname}
158 \@namedef{cite }{\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}
160 %  Make \@citex refer to \citen:
162 \def\@citex[#1]#2{\@cite{\citen{#2}}{#1}}%
164 %  Replacement for \@cite which defines the formatting normally done
165 %  around the citation list.  Minor changes can
166 %  be done by changing \citeleft, \citemid, and \citeright; but in other
167 %  cases it might be necessary to redefine the whole macro.
169 \def\@cite#1#2{$\!{}^{\mbox{\scriptsize{{\leavevmode \cite@adjust
170   \citeleft{#1\if@tempswa \citemid #2\fi
171   \spacefactor\@m % punctuation in note doesn't affect outside
172   }\citeright}}}}$}
174 %  Put a penalty before the citation, and adjust the spacing: if no space
175 %  already or if there is extra space due to some punctuation, then change
176 %  to one inter-word space.
178 \@ifundefined{cite@adjust}{\def\cite@adjust{%
179   \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip
180   \ifnum\lastpenalty=\z@ \penalty\@highpenalty \fi
181   \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag
182   \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi}}{}
184 \edef\@zero@skip{\the\z@skip}
186 % \nocite: This is changed to ignore *ALL* spaces and be robust.  The
187 % parameter list, with spaces removed, is `returned' in \@no@sparg, which
188 % is used by \citen.
190 \edef\nocite{\noexpand\protect\expandafter\noexpand\csname nocite \endcsname}
192 \@namedef{nocite }#1{\@bsphack \@nocite{#1}%
193  \@for \@citeb:=\@no@sparg\do{\@ifundefined{b@\@citeb\@extra@b@citeb}%
194     {\G@refundefinedtrue\@warning{Citation `\@citeb' undefined}%
195     \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}}{}}%
196  \@esphack}
198 \def\@nocite#1{\xdef\@no@sparg{\@ignsp#1 \! }% remove *ALL* spaces
199  \if@filesw \immediate\write\@auxout {\string\citation {\@no@sparg}}\fi}
201 % for ignoring *ALL* spaces in the input.  This presumes there are no
202 % \outer tokens and no \if-\fi constructs in the parameter.  Spaces inside
203 % braces are retained.
205 \def\@ignsp#1 {\ifx\!#1\@empty\else #1\expandafter\@ignsp\fi}
207 \let\nocitecount\relax  % in case \nocitecount was used for drftcite
209 \@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}
210 %  in case no fancy bib package (chapterbib) defines this
212 \@ifundefined{G@refundefinedtrue}{\let\G@refundefinedtrue\relax}{}
214 \citenum % execute restore-catcodes
216 % Aliases:
217 \let\citenum\citen
218 \let\citeonline\citen
220 \endinput
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224                       CITE.STY
226 Modify LaTeX's normal citation mechanism to:
228 o Sort citation numbers into ascending order; print non-numbers before
229   numbers.  Compress lists of three or more consecutive numbers to one
230   number range which can be split, with difficulty, after the dash.
231   All numbers should be greater than zero.  E.g., if you used to get
232   the (nonsense) list [7,5,6,?,4,9,8,Einstein,6], then this style
233   will give you [?,Einstein,4-6,6-9].
235 o Allow, but strongly discourage, line breaks within a series of
236   citations.  Each number is separated by a comma and a small space.
237   A break at the beginning of an optional note is discouraged also.
239 o Put a highpenalty before the citation (unless you specifically forbid it
240   with ~ ).  Also, adjust the spacing: if there is no space or if there is
241   extra space due to some punctuation, then change to one inter-word space.
242   E.g.,   Something really stupid\cite{Larry,Curly,Moe}.
243   A space is inserted here ------^
245 o Define \citen to get just the numbers (and write to the aux file)
246   without the brackets and extra formatting (`\citen{x}' -> `12').  The
247   aliases \citenum and \citeonline are also defined the same as \citen
249 o `Citation...undefined' warnings are only given once per undefined
250   citation tag.  In the text, missing numbers are represented with a
251   bold `?' at the first occurrence, and with a normal `?' thenceforth.
253 o Make \nocite, \cite, and \citen all ignore spaces in the input tags.
255 Line-breaks are allowed with extra-high penalties (1000) after dashes
256 and commas; these may have to be taken if TeX sees no other viable
257 break-points.  If you think citations are being split unnecessarily,
258 try using \sloppy or a sloppypar environment.
260 Although each \cite command sorts its numbers, better compression
261 into ranges can usually be achieved by carefully selecting the order
262 of the \bibitem entries or the order of initial citations when using
263 BibTeX.  Having the entries pre-sorted will also save processing time,
264 especially for long lists of numbers.
266 Customization:
267 ~~~~~~~~~~~~~~
268 There are several commands that you may redefine (using \renewcommand)
269 to change the formatting of citation lists:
271  command       function                   default
272 ----------    -----------------------    ----------------------------
273 \citeform     reformats each number      nothing
274 \citepunct    printed between numbers    comma + penalty + thin space
275 \citeleft     left delimiter of list     [
276 \citeright    right delimiter of list    ]
277 \citemid      printed before note        comma + space
278 \citedash     used in a compressed range endash + penalty
280 Under LaTeX2e, there are four options for \usepackage{cite}:
281 [verbose] causes warnings for undefined citations to be repeated each
282           time they are used.
283 [nospace] eliminates the spaces after commas in the number list.
284 [space]   uses a full inter-word space with no penalty after the commas
285 [nosort]  prevents sorting of the numbers (default is to sort, and a
286 [sort]    option is provided for completeness).
287 [noadjust]  disables `smart' handling of space before a cite.
289 Some examples:
290 \renewcommand\citemid{; }  % semicolon+space before optional note
291 \renewcommand\citeleft{(}  % parentheses around list
292 \renewcommand\citeright{)} % parentheses around list
293 \renewcommand\citepunct{,} % no space and no breaks at commas
294 \renewcommand\citeform[1]{\romannumeral 0#1}} % roman numerals [i,vi]
295 \renewcommand\citeform[1]{(#1)} % parenthesized numbers [(1)-(5)]
296 \renewcommand\citeform{\thechapter.}  % by chapter: [2.18-2.21]
298 The appearance of the whole citation list is governed by \@cite, so for
299 more extensive changes to the formatting, redefine \@cite.  Remember,
300 these formatting controls are part of this package; they are not part
301 of generic LaTeX.
303 Related Note:  cite.sty does not affect the numbering format of the
304 bibliography; the "[12]" style is still the default.  To change that
305 format (with or without cite.sty) you can redefine \@biblabel, including
307    \renewcommand\@biblabel[1]{#1.}
309 in your personal style file, or with, for example,
311    \makeatletter \renewcommand\@biblabel[1]{(#1)} \makeatother
313 directly in your document.  If these do not work, your LaTeX and/or
314 document style are very outdated.
316 \@extra@b@citeb is a hook for other style files to further specify
317 citations; for example, to number by chapter (see chapterbib.sty).
319 See also overcite.sty and drftcite.sty for superscript and draft
320 mode citations.
322 % Version 1989: Original.
323 % Version 1991: Ignore spaces after commas in the parameter list. Move most of
324 % \citen into \@compress@cite for speed.
325 % Version 1992: Use \citepunct for commas so it is easier to change.
327 % Version 3.0 (1992):  Rewrite, including sorting.  Make entries like "4th"
328 % be treated properly as text.
329 % 3.1: Bug fixes (and Joerg-Martin Schwarz also convinced me to use \ifcat)
330 % 3.2: Suppress repetitions of warning messages. Include \@extra@b@citeb hook.
331 % 3.3: Handle LaTeX2e options. Introduce various customization hooks.
332 % 3.4: Heuristics to avoid removing \hspace glue before the \cite. Make \nocite
333 %      ignore spaces in list, simplify. Aliases for \citen. Compatability with
334 %      amsmath (which defines \over).
335 % 3.6: Include \G@refundefinedtrue and nosort option.
336 % 3.7: catcode preservation and global \@no@sparg for french.sty; warnings
337 %      in \nocite.
338 % 3.8: \citedash hook, noadjust option, hack for babel
340 % Send problem reports to asnd@triumf.ca
342 Test file integrity:  ASCII 32-57, 58-126:  !"#$%&'()*+,-./0123456789
343 :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~