newsavebox named after counter
The following will create saveboxes \MyStringa
to \MyStringz
:
\makeatletter
\count@=0
\loop\ifnum\count@<26
\advance\count@\@ne
\expandafter\newsavebox\csname MyString\@alph\count@\endcsname
\repeat
\makeatother
It's also simple (even simpler) with expl3
:
\usepackage{expl3}
\ExplSyntaxOn
% loop from 1 to 26, #1 denotes the current value in the cycle
\int_step_inline:nn { 26 }
{
\exp_args:Nc \newsavebox { MyString \int_to_alph:n { #1 } }
}
\ExplSyntaxOff
With \exp_args:Nc
we jump over \newsavebox
and form a control sequence token from the braced argument before \newsavebox
is actually performed.
In the log file we'll find something like
\MyStringa=\box46
\MyStringb=\box47
\MyStringc=\box48
[...similar lines...]
\MyStringy=\box70
\MyStringz=\box71
confirming that the allocations have been performed.