diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/sttools/texsort.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/sttools/texsort.sty | 221 |
1 files changed, 99 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/latex/sttools/texsort.sty b/Master/texmf-dist/tex/latex/sttools/texsort.sty index ff54e804ffb..a78fe40bed4 100644 --- a/Master/texmf-dist/tex/latex/sttools/texsort.sty +++ b/Master/texmf-dist/tex/latex/sttools/texsort.sty @@ -1,118 +1,79 @@ -%% texsort.sty -%% Copyright 2000 Sigitas Tolu\v sis +%% +%% This is file `texsort.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% texsort.dtx (with options: `package') +%% +%% Copyright (C) 2000-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> %% VTeX Ltd., Akademijos 4, Vilnius, Lithuania -%% e-mail sigitas@vtex.lt %% http://www.vtex.lt/tex/download/macros/ +%% -------------------------------------------------------------------------- +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. %% -% This program can redistributed and/or modified under the terms -% of the LaTeX Project Public License Distributed from CTAN -% archives in directory macros/latex/base/lppl.txt; either -% version 1 of the License, or (at your option) any later version. -% -% PURPOSE: Sort/compress numerical lists -% -% SHORT DESCRIPTION: -% -% \initarray#1#2 -% -------------- -% Converts list #2 to array #1 -% -% \outarray#1\sep#2 -% ----------------- -% Outputs array #1 elements separated by #2 -% -% \getarrayitem#1#2\to#3 -% ---------------------- -% Gets #2'th element from array #1 to \csname#3\endcsname -% -% \setarrayitem#1#2#3 -% ------------------- -% Sets #2'th element from array #1 to numeric value #3 -% -% \getarraylenght#1 -% ----------------- -% Gets array #1 elements count -% -% \setarraylenght#1 -% ----------------- -% Sets array #1 elements count to value #2 -% -% \upheap#1#2; \insertheapelem#1#2; \downheap#1#2; \removetop#1\to#2 -% ------------------------------------------------------------------ -% Internal macros of sort algorithm -% -% \g@addto@macrobeg#1#2 -% --------------------- -% Adds defs #2 to macro #1 begining -% -% \add@zero#1 -% ----------- -% Adds 0 before #1 -% -% \sortlistarray#1\to#2 -% --------------------- -% Sorts array #1 to array #2 -% -% \sortlist#1\to#2\sep#3 -% ---------------------- -% Sorts list #1 and puts to macro #2; elements separated by #3 -% -% \compresslist#1\to#2\sep#3#4 -% ---------------------------- -% Compress list #1 and puts to macro #2; -% single elements separated by #3, multi by #4 -% -% Changes: -% \changes{2000/06/06}{alfa version} -% \changes{2000/06/08}{added compression} -% +%% PURPOSE: Sort/compress numerical lists +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{texsort} + [2012/05/29 v1.1 Sort/compress alphanumerical list] \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{texsort}[2000/06/08] -% +\ProvidesPackage{texsort}[2012/05/29] \newcount\t@mp@r@a \newcount\t@mp@r@b \newcount\t@mp@r@c - \def\initarray#1#2{% \bgroup \@tempcnta=\z@ \@for\@@refb:=#2\do{% \advance\@tempcnta by\@ne \bgroup - \setbox0\hbox{\expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero\@@refb\relax}% - \ifdim\wd0>\z@\relax\@latex@warning{Negrynas skaicius \@@refb!}\fi - \expandafter\edef\csname @a@\endcsname{\expandafter\xdef\expandafter - \noexpand\csname#1@\the\@tempcnta\endcsname{\the\t@mp@r@a}}\@a@ + \setbox\z@\hbox{% + \expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero\@@refb\relax + }% + \ifdim\wd0>\z@\relax + \@latex@warning{Not number \@@refb!}% + \fi + \expandafter\edef\csname @a@\endcsname{\expandafter\xdef\expandafter + \noexpand\csname#1@\the\@tempcnta\endcsname{\the\t@mp@r@a}}\@a@ \egroup }% \expandafter\xdef\csname #1@lenght\endcsname{\the\@tempcnta}% \egroup -} + } \def\outarray#1\sep#2{% \bgroup \@tempcnta=\z@\relax \@tempcntb=\getarraylenght{#1}% \loop - \ifnum\@tempcnta<\@tempcntb - \advance\@tempcnta by1\relax - \ifnum\@tempcnta>1\relax#2\fi\csname#1@\the\@tempcnta\endcsname + \ifnum\@tempcnta<\@tempcntb + \advance\@tempcnta by\@ne\relax + \ifnum\@tempcnta>\@ne\relax#2\fi + \csname#1@\the\@tempcnta\endcsname \repeat \egroup -} + } \def\add@zero#1{0#1} \def\getarrayitem#1#2\to#3{\expandafter\xdef\csname#3\endcsname{\csname#1@#2\endcsname}} \def\setarrayitem#1#2#3{% \bgroup - \setbox0\hbox{\expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero#3\relax}% - \ifdim\wd0>\z@\relax\@latex@warning{Negrynas skaicius #3!}\fi - \expandafter\edef\csname @a@\endcsname{\expandafter\xdef\expandafter - \noexpand\csname#1@#2\endcsname{\the\t@mp@r@a}}\@a@ + \setbox0\hbox{% + \expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero#3\relax + }% + \ifdim\wd0>\z@\relax + \@latex@warning{Not number #3!}% + \fi + \expandafter\xdef\csname#1@#2\endcsname{\the\t@mp@r@a}% \egroup -} + } \def\getarraylenght#1{\@ifundefined{#1@lenght}{0}{\csname #1@lenght\endcsname}} \def\setarraylenght#1#2{\expandafter\xdef\csname #1@lenght\endcsname{#2}} - -%#1 - masyvas, #2 - elemento nr. \def\upheap#1#2{% \bgroup \getarrayitem{#1}{#2}\to{vara}% @@ -121,27 +82,24 @@ \loop \@tempcnta=\@tempcntb \divide\@tempcnta by2\getarrayitem{#1}{\the\@tempcnta}\to{varb}% - \ifnum\varb>\vara\relax\else + \ifnum\varb>\vara\relax + \else \getarrayitem{#1}{\the\@tempcnta}\to{varb}% \setarrayitem{#1}{\the\@tempcntb}{\varb}% \divide\@tempcntb by2\relax \repeat \setarrayitem{#1}{\the\@tempcntb}{\vara}% \egroup -} - -%#1 - masyvas, #2 - dedama reiksme + } \def\insertheapelem#1#2{% - \bgroup + \bgroup \@tempcnta=\getarraylenght{#1}\relax \advance\@tempcnta by1\relax \setarraylenght{#1}{\the\@tempcnta}\relax \setarrayitem{#1}{\the\@tempcnta}{#2}% \upheap{#1}{\the\@tempcnta}% \egroup -} - -%#1 - masyvas, #2 - elemento nr. + } \newcount\@tempcntd \def\downheap#1#2{% \bgroup @@ -151,9 +109,10 @@ \divide\@tempcntb by2\relax \t@mp@r@b=\@tempcntb\relax \@tempcntb=#2\relax - \ifnum\@tempcntb>\t@mp@r@b\relax\else + \ifnum\@tempcntb>\t@mp@r@b\relax + \else \loop - \@tempcnta=\@tempcntb\advance\@tempcnta by\@tempcntb\relax + \@tempcnta=\@tempcntb \advance\@tempcnta by\@tempcntb\relax \@tempcntd=\@tempcnta \advance\@tempcntd by1\relax \ifnum\@tempcnta<\t@mp@r@c\relax \getarrayitem{#1}{\the\@tempcnta}\to{temp@@a}% @@ -176,7 +135,7 @@ \fi \setarrayitem{#1}{\the\@tempcntb}{\vara}% \egroup -} + } \def\removetop#1\to#2{% \bgroup @@ -190,46 +149,48 @@ \setarraylenght{#1}{\the\@tempcnta}% \downheap{#1}{1}% \egroup -} + } \long\def\g@addto@macrobeg#1#2{% \begingroup \def\@a@{#2}% \toks@\expandafter\expandafter\expandafter{\expandafter\@a@#1}% \xdef#1{\the\toks@}% - \endgroup} - + \endgroup + } \def\sortlistarray#1\to#2{% \bgroup \@for\@@refb:=#1\do{% \insertheapelem{@tempa@}{\@@refb}% - }% + }% \@tempcntb=\getarraylenght{@tempa@}% \setarraylenght{#2}{\the\@tempcntb}% \@for\@@refb:=#1\do{% \removetop{@tempa@}\to{aka}% \setarrayitem{#2}{\the\@tempcntb}{\aka}% \advance\@tempcntb by-1\relax - }% + }% \egroup -} + } \def\sortlist#1\to#2\sep#3{% \bgroup \@for\@@refb:=#1\do{% \insertheapelem{@tempa@}{\@@refb}% - }% + }% \@tempcntb=\getarraylenght{@tempa@}% \expandafter\def\csname#2\endcsname{}% \expandafter\def\expandafter\@a@\expandafter{\csname#2\endcsname}% \@for\@@refb:=#1\do{% \removetop{@tempa@}\to{aka}% \advance\@tempcntb by-1\relax - \expandafter\expandafter\expandafter\g@addto@macrobeg\expandafter\@a@\expandafter{\aka}% + \expandafter\expandafter\expandafter + \g@addto@macrobeg\expandafter\@a@\expandafter{\aka}% \ifnum\@tempcntb>0\relax - \expandafter\expandafter\expandafter\g@addto@macrobeg\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macrobeg\expandafter\@a@\expandafter{#3}% \fi - }% + }% \egroup -} + } \def\compresslist#1\to#2\sep#3#4{% \bgroup \expandafter\def\csname#2\endcsname{}% @@ -241,12 +202,15 @@ \t@mp@r@a=\@@refb\relax \t@mp@r@b=\@@refb\relax \t@mp@r@c=\@@refb\relax - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@a}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@a}% \else \t@mp@r@c=\@@refb\relax \ifnum\t@mp@r@c=\t@mp@r@a\relax - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#3}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% \t@mp@r@b=\t@mp@r@c\relax \else \@tempcnta=\t@mp@r@b\relax @@ -257,33 +221,46 @@ \@tempcnta=\t@mp@r@a\relax \advance\@tempcnta by-\t@mp@r@b\relax \ifnum\@tempcnta<-1\relax - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#4}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#3}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#4}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% \else \ifnum\t@mp@r@a<\t@mp@r@b - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#3}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}% \fi - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#3}% - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% \fi \t@mp@r@a=\t@mp@r@c\relax \t@mp@r@b=\t@mp@r@c\relax \fi \fi \fi - }% + }% \ifnum\t@mp@r@a<\t@mp@r@c\relax \advance\t@mp@r@a by-\t@mp@r@c\relax \ifnum\t@mp@r@a<-1\relax - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#4}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#4}% \else - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{#3}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{#3}% \fi - \expandafter\expandafter\expandafter\g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% + \expandafter\expandafter\expandafter + \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}% \fi \egroup -} + } \endinput +%% +%% End of file `texsort.sty'. |