%% %% This is file 'numcompress'. %% %% Copyright (C) 2009-2012 River Valley Technologies %% %% %% This package may be distributed under the terms of the LaTeX Project %% Public License, as described in lppl.txt in the base LaTeX distribution. %% Either version 1.0 or, at your option, any later version. %% %% $Id: numcompress.sty 187 2012-08-18 09:36:35Z rishi $ %% $URL: http://lenova.river-valley.com/svn/elsbst/trunk/numcompress.sty $ %% \NeedsTeXFormat{LaTeX2e} \def\Fileversion$#1: #2 ${\gdef\fileversion{#2}} \def\Filedate$#1: #2-#3-#4 #5 #6 #7 ${\gdef\filedate{#2/#3/#4}} \Fileversion$Rev: 187 $ \Filedate$LastChangedDate: 2012-08-18 15:06:35 +0530 (Sat, 18 Aug 2012) $ \ProvidesPackage{numcompress} [\filedate\space\fileversion\space numcompress (CVR)] \PackageWarningNoLine{numcompress} {****************************************\MessageBreak Package numcompress v,\fileversion\space loaded\MessageBreak [Compress numbers (CVR)]\MessageBreak ****************************************} \newif\ifdots \dotsfalse \newif\ifnumcompress \numcompresstrue \DeclareOption{dots}{\global\dotstrue} \DeclareOption{nodots}{\global\dotsfalse} \DeclareOption{compress}{\global\numcompresstrue} \DeclareOption{nocompress}{\global\numcompressfalse} \ProcessOptions \def\removeDot#1{\def\tmp{#1}% \ifx\tmp\@empty\else\@removeDot#1\@nil\fi} \def\@removeDot#1\@nil{\edef\fchar{\expandafter\@car#1\@nil}% \edef\rchar{\expandafter\@cdr#1!\@nil}% \def\@xmltempa{.}\def\@xmltempb{!}% \ifx\fchar\@xmltempb\relax\else% \ifx\fchar\@xmltempa\relax\else% \fchar\ignorespaces\fi\removeDot{\rchar}\fi} \def\First[#1]{\csname First#1\endcsname} \def\Second[#1]{\csname Second#1\endcsname} \def\parseFirstPage#1{\@tempcnta=0 \@tfor\@digits:=#1\do{% {\global\advance\@tempcnta by 1 \expandafter\xdef\csname First\the\@tempcnta\endcsname{\@digits}% \xdef\flength{\the\@tempcnta}}}} \def\parseSecondPage#1{\@tempcnta=0 \@tfor\@digits:=#1\do{% {\global\advance\@tempcnta by 1 \expandafter\xdef\csname Second\the\@tempcnta\endcsname{\@digits}% \xdef\llength{\the\@tempcnta}}}} \newif\ifdissimilar\dissimilarfalse \def\checkequal#1#2{\edef\Farg{#1}\edef\Sarg{#2}% \edef\One{A}% \ifcat\One\Farg \relax\else% \ifdissimilar\Sarg\else% \ifnum\Farg=\Sarg\relax\else\Sarg\dissimilartrue\fi\fi\fi} % \let\@@fpage\@empty \let\@@lpage\@empty \def\fpage@compress#1{% \gdef\@@fpage{#1}% \edef\llength{0}% \parseFirstPage{#1}% \ifnum\flength=\llength% \gdef\@fpage{\@@fpage}% \gdef\@lpage{% \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}% \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}% \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}% \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}% \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}% }% \else% \gdef\@fpage{\@@fpage}% \gdef\@lpage{\@@lpage}% \fi} \def\lpage@compress#1{% \gdef\@@lpage{#1}% \parseSecondPage{#1}% \ifnum\flength=\llength% \gdef\@fpage{\@@fpage}% \gdef\@lpage{% \edef\One{A}% \edef\xFirst{\First[1]}% \edef\xSecond{\Second[1]}% \ifcat\One\xSecond\relax% \ifx\xFirst\xSecond% \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}% \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}% \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}% \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}% \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}% \else#1\fi% \else% \ifx\xFirst\xSecond% \@ifundefined{Second1}{}{\checkequal{\First[1]}{\Second[1]}}% \@ifundefined{Second2}{}{\checkequal{\First[2]}{\Second[2]}}% \@ifundefined{Second3}{}{\checkequal{\First[3]}{\Second[3]}}% \@ifundefined{Second4}{}{\checkequal{\First[4]}{\Second[4]}}% \@ifundefined{Second5}{}{\checkequal{\First[5]}{\Second[5]}}% \else#1\fi% \fi% }% \else \gdef\@fpage{\@@fpage}% \gdef\@lpage{% \edef\Targ{#1}% \edef\One{A}% \edef\xFirst{\First[1]}% \edef\xSecond{\Second[1]}% \ifx\xFirst\xSecond \ifcat\One\xSecond\relax\else\@@lpage\fi% \else#1\fi% }% \fi} %\newwrite\xx %\immediate\openout\xx=tmpbib.tex \gdef\@@lpage@compress#1--#2\@nil{\lpage@compress{#1}} \gdef\@@@pages#1#2{\def\next{#2}% % \immediate\write\xx{[\the\c@NAT@ctr.]\space [#1][#2]}% \fpage@compress{#1}%\ifx\next\@empty\relax\else \@@lpage@compress#2\@nil%\fi {\@fpage\ifx\next\@empty\relax\else --\@lpage\fi}\resetall} \gdef\@@@page#1{#1\resetall} \def\mk@empty#1{\@tempcnta=1 \loop\ifnum\@tempcnta<6 \expandafter\let\csname#1\the\@tempcnta\endcsname\relax \advance\@tempcnta by 1 \repeat} \def\resetall{\let\@lpage\@empty\let\@fpage\@empty \def\flength{0}\def\llength{0}% \let\@@fpage\@empty\let\@@lpage\@empty \mk@empty{First}\mk@empty{Second}} \ifdots \gdef\xfnm[#1]{\unskip\space#1} \def\bibinfo#1#2{\@ifnextchar.{\@@bibinfo{#1}{#2}}{\@@@bibinfo{#1}{#2}}} \def\@@@bibinfo#1#2{\def\next{#1}% \def\@@@pg{pages}\def\@@@au{author}% \ifx\next\@@@pg\bibpages{#2}\else \ifx\next\@@@au\bibauthor{#2}\else #2\fi\fi} \def\@@bibinfo#1#2.{\def\next{#1}% \def\@@@pg{pages}\def\@@@au{author}% \ifx\next\@@@pg\bibpages{#2}.\else \ifx\next\@@@au\bibauthor{#2}\else #2.\fi\fi} \else \gdef\xfnm[#1]{\unskip\space\removeDot{#1}} \def\bibinfo#1#2{\def\next{#1}% \def\@@@pg{pages}\def\@@@au{author}% \ifx\next\@@@pg\bibpages{#2}\else \ifx\next\@@@au\bibauthor{#2}\else #2\fi\fi} \fi \ifnumcompress \def\bibpages#1{\@@bibpages#1--\\\@nil} \def\@@bibpages#1--#2\@nil{% \ifx\\#2\relax\@@@page{#1}\else \@@@pages{#1}{#2}\fi} \else \def\bibpages#1{#1} \fi \def\bibauthor#1{#1} \endinput %% %% End of package 'numcompress.sty' %%