/articles/adei2016

To get this branch, use:
bzr branch http://darksoft.org/webbzr/articles/adei2016
1 by Suren A. Chilingaryan
Initial import
1
%NAME: citesort.sty
2
% A replacement for \@citex which sorts citation numbers as well as
3
% compressing and allowing breaks.  Based on cite.sty by Donald
4
% Arseneau.
5
%
6
% for use in LaTeX say, \documentstyle[...,citesort,...]{...}
7
%
8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9
%     Allow, but strongly discourage, line breaks within a long
10
%     series of citations.  Compress lists of successive numbers
11
%     to one number range, e.g., 5,6,7,8,9 --> 5--9.  Compatible
12
%     with versions of \@cite that use exponents.
13
%              -- Donald Arseneau  1989
14
%
15
% Modified to sort the numbers so they come out in increasing order,
16
% regardless of the way they appear in the source. O(N^2) sort!
17
% Ian Green, CUED, 10-Dec-1991.  Improvements to img@eng.cam.ac.uk
18
% please. Version 1
19
20
\newcount\@minsofar
21
\newcount\@min
22
\newcount\@cite@temp
23
\def\@citex[#1]#2{%
24
\if@filesw \immediate \write \@auxout {\string \citation {#2}}\fi
25
\@tempcntb\m@ne \let\@h@ld\relax \def\@citea{}%
26
\@min\m@ne%
27
\@cite{%
28
  \@for \@citeb:=#2\do {\@ifundefined {b@\@citeb}%
29
    {\@h@ld\@citea\@tempcntb\m@ne{\bf ?}%
30
    \@warning {Citation `\@citeb ' on page \thepage \space undefined}}%
31
{\@minsofar\z@ \@for \@scan@cites:=#2\do {%
32
  \@ifundefined{b@\@scan@cites}%
33
    {\@cite@temp\m@ne}
34
    {\@cite@temp\number\csname b@\@scan@cites \endcsname \relax}%
35
\ifnum\@cite@temp > \@min% select the next one to list
36
    \ifnum\@minsofar = \z@
37
      \@minsofar\number\@cite@temp
38
      \edef\@scan@copy{\@scan@cites}\else
39
    \ifnum\@cite@temp < \@minsofar
40
      \@minsofar\number\@cite@temp
41
      \edef\@scan@copy{\@scan@cites}\fi\fi\fi}\@tempcnta\@min
42
  \ifnum\@minsofar > \z@ % some more
43
    \advance\@tempcnta\@ne
44
    \@min\@minsofar
45
    \ifnum\@tempcnta=\@minsofar %   Number follows previous--hold on to it
46
      \ifx\@h@ld\relax
47
        \edef \@h@ld{\@citea\csname b@\@scan@copy\endcsname}%
48
      \else \edef\@h@ld{\ifmmode{-}\else--\fi\csname b@\@scan@copy\endcsname}%
49
      \fi
50
    \else \@h@ld\@citea\csname b@\@scan@copy\endcsname
51
          \let\@h@ld\relax
52
  \fi % no more
53
\fi}%
54
\def\@citea{,\penalty\@highpenalty\,}}\@h@ld}{#1}}
55
56
% end of citesort.sty