Updated by Alexis Bienvenüe almost 11 years ago


\copygroup[n]{groupA}{groupB} copies the first n elements from groupA to groupB

I needed a command \pickgroup[n]{groupA}{groupB} very similar which would pick the n^th element from groupA and place to groupB.
Also I needed a command \rangegroup[n][m]{groupA}{groupB} to get the elements from 'n' to 'm' from groupA and place to groupB.

I wrote myself such commands by "rewording" \copygroup, but since I never programmed LaTeX before, maybe some of you guys could check it up.

Cheers,
Andrea

----------------
<pre>
\newcommand{\pickgroup}[3][1]{
\AMCtok@max=#1\relax
\ifnum\the\AMCtok@max<1
\AMCtok@max=\csname #2@k\endcsname
\fi
\AMCtok@ik=\z@
{\loop
\advance\AMCtok@ik\@ne\relax%
\ifnum\the\AMCtok@ik<#1\relax%
\else
\AMC@prepare@element{#3}%
\global\csname #3@\romannumeral\AMCtok@k\endcsname=\csname #2@\romannumeral\AMCtok@ik\endcsname%
\fi
\ifnum\AMCtok@ik<\AMCtok@max\repeat}%
}
\newcommand{\rangegroup}[4][1]{
\AMCtok@max=#2\relax%
\ifnum\the\AMCtok@max<1%
\AMCtok@max=\csname #3@k\endcsname%
\fi%
\AMCtok@ik=\z@%
{\loop%
\advance\AMCtok@ik\@ne\relax%
\ifnum\the\AMCtok@ik<#1\relax%
\else
\AMC@prepare@element{#4}%
\global\csname #4@\romannumeral\AMCtok@k\endcsname=\csname #3@\romannumeral\AMCtok@ik\endcsname%
\fi
\ifnum\AMCtok@ik<\AMCtok@max\repeat}%
}
</pre>

Back