]> AND Private Git Repository - kahina_paper1.git/blob - numcompress.sty
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
MAJ Mybib
[kahina_paper1.git] / numcompress.sty
1 %%
2 %% This is file 'numcompress'.
3 %%
4 %% Copyright (C) 2009-2012 River Valley Technologies 
5 %%                    <latex.support@river-valley.com>
6 %%   
7 %% This package may be distributed under the terms of the LaTeX Project 
8 %% Public License, as described in lppl.txt in the base LaTeX distribution.
9 %% Either version 1.0 or, at your option, any later version.
10 %%
11 %% $Id: numcompress.sty 187 2012-08-18 09:36:35Z rishi $
12 %% $URL: http://lenova.river-valley.com/svn/elsbst/trunk/numcompress.sty $
13 %%
14 \NeedsTeXFormat{LaTeX2e}
15 \def\Fileversion$#1: #2 ${\gdef\fileversion{#2}}
16 \def\Filedate$#1: #2-#3-#4 #5 #6 #7 ${\gdef\filedate{#2/#3/#4}} 
17 \Fileversion$Rev: 187 $
18 \Filedate$LastChangedDate: 2012-08-18 15:06:35 +0530 (Sat, 18 Aug 2012) $
19 \ProvidesPackage{numcompress}
20    [\filedate\space\fileversion\space numcompress (CVR)]
21 \PackageWarningNoLine{numcompress}
22    {****************************************\MessageBreak
23     Package numcompress v,\fileversion\space loaded\MessageBreak
24     [Compress numbers (CVR)]\MessageBreak
25     ****************************************}
26 \newif\ifdots \dotsfalse
27 \newif\ifnumcompress \numcompresstrue
28
29 \DeclareOption{dots}{\global\dotstrue}
30 \DeclareOption{nodots}{\global\dotsfalse}
31 \DeclareOption{compress}{\global\numcompresstrue}
32 \DeclareOption{nocompress}{\global\numcompressfalse}
33
34 \ProcessOptions 
35
36 \def\removeDot#1{\def\tmp{#1}%
37     \ifx\tmp\@empty\else\@removeDot#1\@nil\fi}
38
39 \def\@removeDot#1\@nil{\edef\fchar{\expandafter\@car#1\@nil}%
40       \edef\rchar{\expandafter\@cdr#1!\@nil}%
41       \def\@xmltempa{.}\def\@xmltempb{!}%
42       \ifx\fchar\@xmltempb\relax\else%
43       \ifx\fchar\@xmltempa\relax\else%
44       \fchar\ignorespaces\fi\removeDot{\rchar}\fi}
45
46 \def\First[#1]{\csname First#1\endcsname}
47 \def\Second[#1]{\csname Second#1\endcsname}
48
49 \def\parseFirstPage#1{\@tempcnta=0
50   \@tfor\@digits:=#1\do{%
51     {\global\advance\@tempcnta by 1
52       \expandafter\xdef\csname
53       First\the\@tempcnta\endcsname{\@digits}%
54       \xdef\flength{\the\@tempcnta}}}}
55
56 \def\parseSecondPage#1{\@tempcnta=0
57   \@tfor\@digits:=#1\do{%
58     {\global\advance\@tempcnta by 1
59       \expandafter\xdef\csname
60       Second\the\@tempcnta\endcsname{\@digits}%
61       \xdef\llength{\the\@tempcnta}}}}
62
63 \newif\ifdissimilar\dissimilarfalse
64 \def\checkequal#1#2{\edef\Farg{#1}\edef\Sarg{#2}%
65       \edef\One{A}%
66       \ifcat\One\Farg \relax\else%
67       \ifdissimilar\Sarg\else%
68       \ifnum\Farg=\Sarg\relax\else\Sarg\dissimilartrue\fi\fi\fi}
69 %
70 \let\@@fpage\@empty
71 \let\@@lpage\@empty
72 \def\fpage@compress#1{%
73       \gdef\@@fpage{#1}%
74             \edef\llength{0}%
75             \parseFirstPage{#1}%
76       \ifnum\flength=\llength%
77        \gdef\@fpage{\@@fpage}%
78        \gdef\@lpage{%
79         \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}%
80         \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}%
81         \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}%
82         \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}%
83         \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}%
84       }%
85       \else%
86        \gdef\@fpage{\@@fpage}%
87        \gdef\@lpage{\@@lpage}%
88      \fi}
89
90 \def\lpage@compress#1{%
91         \gdef\@@lpage{#1}%
92         \parseSecondPage{#1}%
93       \ifnum\flength=\llength%
94        \gdef\@fpage{\@@fpage}%
95        \gdef\@lpage{%
96        \edef\One{A}%
97        \edef\xFirst{\First[1]}%
98        \edef\xSecond{\Second[1]}%
99        \ifcat\One\xSecond\relax%
100           \ifx\xFirst\xSecond%
101            \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}%
102            \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}%
103            \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}%
104            \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}%
105            \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}%
106           \else#1\fi%
107       \else%
108           \ifx\xFirst\xSecond%
109            \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}%
110            \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}%
111            \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}%
112            \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}%
113            \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}%
114         \else#1\fi%
115       \fi%
116       }%
117     \else
118       \gdef\@fpage{\@@fpage}%
119       \gdef\@lpage{%
120       \edef\Targ{#1}%
121       \edef\One{A}%
122       \edef\xFirst{\First[1]}%
123       \edef\xSecond{\Second[1]}%
124       \ifx\xFirst\xSecond
125          \ifcat\One\xSecond\relax\else\@@lpage\fi%
126       \else#1\fi%
127       }%
128   \fi}
129
130 %\newwrite\xx
131 %\immediate\openout\xx=tmpbib.tex
132 \gdef\@@lpage@compress#1--#2\@nil{\lpage@compress{#1}}
133 \gdef\@@@pages#1#2{\def\next{#2}%
134 %  \immediate\write\xx{[\the\c@NAT@ctr.]\space [#1][#2]}%
135   \fpage@compress{#1}%\ifx\next\@empty\relax\else
136    \@@lpage@compress#2\@nil%\fi
137   {\@fpage\ifx\next\@empty\relax\else
138     --\@lpage\fi}\resetall}
139
140 \gdef\@@@page#1{#1\resetall}
141
142 \def\mk@empty#1{\@tempcnta=1
143   \loop\ifnum\@tempcnta<6
144     \expandafter\let\csname#1\the\@tempcnta\endcsname\relax
145     \advance\@tempcnta by 1 \repeat}
146 \def\resetall{\let\@lpage\@empty\let\@fpage\@empty
147    \def\flength{0}\def\llength{0}%
148    \let\@@fpage\@empty\let\@@lpage\@empty
149    \mk@empty{First}\mk@empty{Second}}
150
151
152 \ifdots
153  \gdef\xfnm[#1]{\unskip\space#1}
154  \def\bibinfo#1#2{\@ifnextchar.{\@@bibinfo{#1}{#2}}{\@@@bibinfo{#1}{#2}}}
155  \def\@@@bibinfo#1#2{\def\next{#1}%
156    \def\@@@pg{pages}\def\@@@au{author}%
157    \ifx\next\@@@pg\bibpages{#2}\else
158    \ifx\next\@@@au\bibauthor{#2}\else
159    #2\fi\fi}
160  \def\@@bibinfo#1#2.{\def\next{#1}%
161   \def\@@@pg{pages}\def\@@@au{author}%
162   \ifx\next\@@@pg\bibpages{#2}.\else
163   \ifx\next\@@@au\bibauthor{#2}\else
164   #2.\fi\fi}
165 \else
166  \gdef\xfnm[#1]{\unskip\space\removeDot{#1}}
167  \def\bibinfo#1#2{\def\next{#1}%
168    \def\@@@pg{pages}\def\@@@au{author}%
169    \ifx\next\@@@pg\bibpages{#2}\else
170    \ifx\next\@@@au\bibauthor{#2}\else
171    #2\fi\fi}
172 \fi
173
174 \ifnumcompress
175  \def\bibpages#1{\@@bibpages#1--\\\@nil}
176  \def\@@bibpages#1--#2\@nil{%
177    \ifx\\#2\relax\@@@page{#1}\else
178    \@@@pages{#1}{#2}\fi}
179  \else
180  \def\bibpages#1{#1}
181 \fi
182
183 \def\bibauthor#1{#1}
184
185 \endinput
186
187 %%
188 %% End of package 'numcompress.sty'
189 %%