diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-09 23:55:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-09 23:55:47 +0000 |
commit | 9dbc25b4e44ce350c7bc495e01ef15fdc48d513a (patch) | |
tree | dc6b7ff87029d188c7c7663568f7856918750ef0 /Master/texmf-dist/tex | |
parent | 6b6cdb5a62b8daaafcfd6a7fbea94c0510a2765c (diff) |
coollist update (9sep09)
git-svn-id: svn://tug.org/texlive/trunk@15194 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/coollist/coollist.sty | 234 |
1 files changed, 127 insertions, 107 deletions
diff --git a/Master/texmf-dist/tex/latex/coollist/coollist.sty b/Master/texmf-dist/tex/latex/coollist/coollist.sty index b5bc871e77f..052ea198fe6 100644 --- a/Master/texmf-dist/tex/latex/coollist/coollist.sty +++ b/Master/texmf-dist/tex/latex/coollist/coollist.sty @@ -13,7 +13,7 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{coollist} - [2007/10/06 v1.2 COntent Oriented LaTeX Lists] + [2007/10/14 v1.3 COntent Oriented LaTeX Lists] \RequirePackage{ifthen} \RequirePackage{amsmath} \RequirePackage{amssymb} @@ -34,7 +34,6 @@ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcounter{COOL@listlen}% \newcommand{\COOL@listEnd}{@@@}% \newcommand{\COOL@listStop}{@@}% @@ -44,54 +43,55 @@ \newboolean{COOL@found}% \def\COOL@listgobble[#1]#2,#3,\COOL@listEnd{% \ifthenelse{\equal{#3}{\COOL@listStop}}% - {% - \ifthenelse{\value{COOL@listpointer}=#1}% {% - \setboolean{COOL@found}{true}% - #2% + \ifthenelse{\value{COOL@listpointer}=#1}% + {% + \setboolean{COOL@found}{true}% + #2% + }% + % Else + {% + }% }% - % Else {% + \ifthenelse{\value{COOL@listpointer}=#1}% + {% + \setboolean{COOL@found}{true}% + #2% + }% + % Else + {% + }% + \stepcounter{COOL@listpointer}% + \COOL@listgobble[#1]#3,\COOL@listEnd% }% - }% - {% - \ifthenelse{\value{COOL@listpointer}=#1}% +}% +\newcommand{\listval}[2]{% +\ifthenelse{\equal{#1}{}}% {% - \setboolean{COOL@found}{true}% - #2% + \setcounter{COOL@listpointer}{0}% }% - % Else {% + \setcounter{COOL@listpointer}{1}% + \setboolean{COOL@found}{false}% + \COOL@listgobble[#2]#1,\COOL@listStop,\COOL@listEnd% }% - \stepcounter{COOL@listpointer}% - \COOL@listgobble[#1]#3,\COOL@listEnd% - }% -}% -\newcommand{\listval}[2]{% -\ifthenelse{\equal{#1}{}}% - {% - \setcounter{COOL@listpointer}{0}% - }% - {% - \setcounter{COOL@listpointer}{1}% - \setboolean{COOL@found}{false}% - \COOL@listgobble[#2]#1,\COOL@listStop,\COOL@listEnd% - }% }% \def\COOL@liststore@gobbler[#1]#2,#3,\COOL@listEnd{% \ifthenelse{\equal{#3}{\COOL@listStop}}% - {% - \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% - }% - {% - \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% - \stepcounter{COOL@listpointer}% - \COOL@liststore@gobbler[#1]#3,\COOL@listEnd% - }% + {% + \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% + }% + {% + \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% + \stepcounter{COOL@listpointer}% + \COOL@liststore@gobbler[#1]#3,\COOL@listEnd% + }% } \newcommand{\liststore}[2]{% \setcounter{COOL@listpointer}{1}% \COOL@liststore@gobbler[#2]#1,\COOL@listStop,\COOL@listEnd% +\expandafter\xdef\csname #2length\endcsname{\arabic{COOL@listpointer}}% }% \newcommand{\listlen}[1]{% \listval{#1}{0}% @@ -101,94 +101,114 @@ \listval{#2}{0}% \setcounter{#1}{\value{COOL@listpointer}} }%listlength +\newcommand{\listcopy}[2]{% +\setcounter{COOL@listlen}{\csname #1length\endcsname}% +\forloop{COOL@listpointer}{1}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% + {% + \expandafter\xdef\csname #2\roman{COOL@listpointer}\endcsname{\csname #1\roman{COOL@listpointer}\endcsname}% + }% +\expandafter\xdef\csname #2length\endcsname{\csname #1length\endcsname}% +} \newcounter{COOL@intsum} \newcounter{COOL@register@ct} \newcounter{COOL@register@len} \newboolean{COOL@listsum@isint} -\newcommand{\listsum}[2]{% -\liststore{#1}{COOL@listtosum@element@}% -\listlenstore{COOL@listlen}{#1}% -\ifthenelse{ \value{COOL@listlen} < 1 }% - {% - \PackageWarning{cool}{List is empty}% - \xdef#2{0}% - }% - {% - \isint{\COOL@listtosum@element@i}{COOL@listsum@isint}% - \ifthenelse{ \boolean{COOL@listsum@isint} }% +\newcommand{\listsum}[3][liststored=false]{% +\ifthenelse{ \equal{#1}{liststored=false} }% + {% + \liststore{#2}{COOL@listtosum@element@}% + \listlenstore{COOL@listlen}{#2}% + }% +{ \ifthenelse{ \equal{#1}{liststored=true} }% {% - \xdef\COOL@listsum@register@integers{\COOL@listtosum@element@i}% - \setcounter{COOL@register@len}{0}% + \listcopy{#2}{COOL@listtosum@element@}% + \setcounter{COOL@listlen}{\COOL@listtosum@element@length}% }% {% - \gdef\COOL@listsum@register@integers{0}% - \xdef\COOL@listsum@register@i{\COOL@listtosum@element@i}% - \gdef\COOL@listsum@register@coef@i{1}% - \setcounter{COOL@register@len}{1}% + \PackageError{cool}{Invalid listsum optional argument}% + {listsum's optional argument may only be `storedlist=true' or `storedlist=false'}% + }}% +\ifthenelse{ \value{COOL@listlen} < 1 }% + {% + \PackageWarning{cool}{List is empty}% + \xdef#3{0}% }% - \forloop{COOL@listpointer}{2}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% {% - \xdef\COOL@listsum@element{\csname COOL@listtosum@element@\roman{COOL@listpointer}\endcsname}% - \isint{\COOL@listsum@element}{COOL@listsum@isint}% + \isint{\COOL@listtosum@element@i}{COOL@listsum@isint}% \ifthenelse{ \boolean{COOL@listsum@isint} }% - {% - \setcounter{COOL@intsum}{\COOL@listsum@register@integers}% - \addtocounter{COOL@intsum}{\COOL@listsum@element}% - \xdef\COOL@listsum@register@integers{\arabic{COOL@intsum}}% - }% - {% - \setboolean{COOL@found}{false}% - \forloop{COOL@register@ct}{1}{\NOT \value{COOL@register@ct} > \value{COOL@register@len}}% {% - \xdef\COOL@listsum@known@element{% - \csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname% - }% - \ifthenelse{ \equal{\COOL@listsum@element}{\COOL@listsum@known@element} }% - {% - \xdef\COOL@listsum@known@element@coef{% - \csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname% + \xdef\COOL@listsum@register@integers{\COOL@listtosum@element@i}% + \setcounter{COOL@register@len}{0}% + }% + {% + \gdef\COOL@listsum@register@integers{0}% + \xdef\COOL@listsum@register@i{\COOL@listtosum@element@i}% + \gdef\COOL@listsum@register@coef@i{1}% + \setcounter{COOL@register@len}{1}% + }% + \forloop{COOL@listpointer}{2}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% + {% + \xdef\COOL@listsum@element{\csname COOL@listtosum@element@\roman{COOL@listpointer}\endcsname}% + \isint{\COOL@listsum@element}{COOL@listsum@isint}% + \ifthenelse{ \boolean{COOL@listsum@isint} }% + {% + \setcounter{COOL@intsum}{\COOL@listsum@register@integers}% + \addtocounter{COOL@intsum}{\COOL@listsum@element}% + \xdef\COOL@listsum@register@integers{\arabic{COOL@intsum}}% + }% + {% + \setboolean{COOL@found}{false}% + \forloop{COOL@register@ct}{1}{\NOT \value{COOL@register@ct} > \value{COOL@register@len}}% + {% + \xdef\COOL@listsum@known@element{% + \csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname% + }% + \ifthenelse{ \equal{\COOL@listsum@element}{\COOL@listsum@known@element} }% + {% + \xdef\COOL@listsum@known@element@coef{% + \csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname% + }% + \setcounter{COOL@intsum}{\COOL@listsum@known@element@coef}% + \addtocounter{COOL@intsum}{1}% + \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname{\arabic{COOL@intsum}}% + \setboolean{COOL@found}{true}% + }% + {% + }% + }% + \ifthenelse{ \boolean{COOL@found} }% + {}% + {% + \addtocounter{COOL@register@len}{1}% + \expandafter\xdef\csname COOL@listsum@register@\roman{COOL@register@len}\endcsname{\COOL@listsum@element}% + \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@len}\endcsname{1}% + }% }% - \setcounter{COOL@intsum}{\COOL@listsum@known@element@coef}% - \addtocounter{COOL@intsum}{1}% - \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname{\arabic{COOL@intsum}}% - \setboolean{COOL@found}{true}% - }% - {% - }% }% - \ifthenelse{ \boolean{COOL@found} }% - {}% + \xdef\COOL@listsum@result{}% + \ifthenelse{ \NOT \COOL@listsum@register@integers = 0 }% + { + \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@register@integers}% + \ifthenelse{ \NOT \value{COOL@register@len} = 0 }% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result+}% + }{}% + }{}% + \forloop{COOL@register@ct}{1}{ \NOT \value{COOL@register@ct} > \value{COOL@register@len} }% {% - \addtocounter{COOL@register@len}{1}% - \expandafter\xdef\csname COOL@listsum@register@\roman{COOL@register@len}\endcsname{\COOL@listsum@element}% - \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@len}\endcsname{1}% + \edef\COOL@listsum@curcoef{\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname}% + \ifthenelse{ \NOT \COOL@listsum@curcoef = 1}% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@curcoef}% + }{}% + \xdef\COOL@listsum@result{\COOL@listsum@result\csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname}% + \ifthenelse{ \NOT \value{COOL@register@ct} = \value{COOL@register@len} }% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result+}% + }{}% }% - }% - }% - \xdef\COOL@listsum@result{}% - \ifthenelse{ \NOT \COOL@listsum@register@integers = 0 }% - { - \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@register@integers}% - \ifthenelse{ \NOT \value{COOL@register@len} = 0 }% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result+}% - }{}% - }{}% - \forloop{COOL@register@ct}{1}{ \NOT \value{COOL@register@ct} > \value{COOL@register@len} }% - {% - \edef\COOL@listsum@curcoef{\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname}% - \ifthenelse{ \NOT \COOL@listsum@curcoef = 1}% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@curcoef}% - }{}% - \xdef\COOL@listsum@result{\COOL@listsum@result\csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname}% - \ifthenelse{ \NOT \value{COOL@register@ct} = \value{COOL@register@len} }% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result+}% - }{}% + \xdef#3{\COOL@listsum@result}% }% - \xdef#2{\COOL@listsum@result}% - }% } \endinput %% |