From d3fd3960d8402d6f9621d35febef86b241808d99 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 29 Jul 2021 03:00:44 +0000 Subject: CTAN sync 202107290300 --- .../latex/contrib/moderncv/moderncvcollection.sty | 51 ++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'macros/latex/contrib/moderncv/moderncvcollection.sty') diff --git a/macros/latex/contrib/moderncv/moderncvcollection.sty b/macros/latex/contrib/moderncv/moderncvcollection.sty index 73db08ed29..aec3beae81 100644 --- a/macros/latex/contrib/moderncv/moderncvcollection.sty +++ b/macros/latex/contrib/moderncv/moderncvcollection.sty @@ -10,7 +10,7 @@ % identification %------------------------------------------------------------------------------- \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{moderncvcollection}[2021/01/21 v2.1.0 moderncv collections] +\ProvidesPackage{moderncvcollection}[2021-07-28 v2.2.0 moderncv collections] %------------------------------------------------------------------------------- @@ -27,42 +27,48 @@ % creates a new collection % usage: \collectionnew{} -\newcommand*{\collectionnew}[1]{% - \newcounter{collection@#1@count}} +\NewDocumentCommand\collectionnew{m}{% + \newcounter{collection@#1@count}% +}% % adds an item to a collection % usage: \collectionadd[]{}{} -\newcommand*{\collectionadd}[3][]{% +\NewDocumentCommand\collectionadd{ O{} m m }{% \expandafter\def\csname collection@#2@item\roman{collection@#2@count}\endcsname{#3}% - \if\relax\noexpand#1\relax% if #1 is empty - \else\expandafter\def\csname collection@#2@key\roman{collection@#2@count}\endcsname{#1}\fi% - \stepcounter{collection@#2@count}} - + \def\optional@FirstArg{#1}% + \ifdefempty{\optional@FirstArg}{% + \relax% if #1 is empty + }{% + \expandafter\def\csname collection@#2@key\roman{collection@#2@count}\endcsname{#1}% + }% + \stepcounter{collection@#2@count}% +}% % returns the number of items in a collection % usage: \collectioncount{} -\newcommand*{\collectioncount}[1]{% - \value{collection@#1@count}} - +\NewDocumentCommand\collectioncount{m}{% + \value{collection@#1@count}% +}% % gets an item from a collection % usage: \collectiongetitem{}{} % where is an integer between 0 and (collectioncount-1) -\newcommand*{\collectiongetitem}[2]{% - \csname collection@#1@item\romannumeral #2\endcsname} +\NewDocumentCommand\collectiongetitem{m m}{% + \csname collection@#1@item\romannumeral #2\endcsname% +}% % gets a key from a collection % usage: \collectiongetkey{}{} % where is an integer between 0 and (collectioncount-1) -\newcommand*{\collectiongetkey}[2]{% - \csname collection@#1@key\romannumeral #2\endcsname} - +\NewDocumentCommand\collectiongetkey{m m}{% + \csname collection@#1@key\romannumeral #2\endcsname% +}% % loops through a collection and perform the given operation on every element % usage: \collectionloop{}{} % where is the code sequence to be evaluated for each collection item, % code which can refer to \collectionloopid, \collectionloopkey, \collectionloopitem and % \collectionloopbreak \newcounter{collection@iterator} -\newcommand*{\collectionloopbreak}{\let\iterate\relax} -\newcommand*{\collectionloop}[2]{% +\NewDocumentCommand\collectionloopbreak{}{\let\iterate\relax} +\NewDocumentCommand\collectionloop{m m}{% \setcounter{collection@iterator}{0}% \loop\ifnum\value{collection@iterator}<\value{collection@#1@count}% \def\collectionloopid{\arabic{collection@iterator}}% @@ -70,14 +76,15 @@ \def\collectionloopkey{\collectiongetkey{#1}{\collectionloopid}}% #2% \stepcounter{collection@iterator}% - \repeat} + \repeat% +} % loops through a collection and finds the (first) element matching the given key % usage: \collectionfindbykey{}{key>} -\newcommand*{\collectionfindbykey}[2]{% +\NewDocumentCommand\collectionfindbykey{m m}{% \collectionloop{#1}{% - \ifthenelse{\equal{\collectionloopkey}{#2}}{\collectionloopitem\collectionloopbreak}{}}} - + \ifthenelse{\equal{\collectionloopkey}{#2}}{\collectionloopitem\collectionloopbreak}{}}% +}% \endinput -- cgit v1.2.3