4

I am trying to write a macro creting automatically a certain number of saveboxes. Therefore I would like to use the concatination of the value of a string and a counter to name the saveboxes. I tried the following and latex complains "Missing Contorl sequence inserted" every time I try to use it.

\newcounter{saveboxCount}
\newsavebox{MyString\alpha{saveboxCount}}
  • 1
    The main problem with your use of \newsavebox is that it requires a control sequence rather than just a string. Hence the use of \csname ...\endcsname to construct the control sequence. – Werner Jul 31 '13 at 20:32
  • @Werner: I noticed that for newsavebox it works if I add the backslash ``, however I have issues with actually using the box later. – ted Jul 31 '13 at 20:36
7

This will create saveboxes \MyStringa to \MyStringz:

\makeatletter
\count@=0
\loop\ifnum\count@<26
  \advance\count@\@ne
  \expandafter\newsavebox\csname MyString\@alph\count@\endcsname
\repeat
\makeatletter
  • why are you using \count@ instead of newcounter? Also any idea why I am seeing errors for \newcommand{\floatRow@resetList}? – ted Jul 31 '13 at 20:29
  • @ted: Is \floatRow@resetList already defined? – Werner Jul 31 '13 at 20:30
  • @Werner: no. I have no idea how to write a package but thought I found something I could work on, and wanted a namespace of my own, e.g. \floatRow@ (I think i should go for something else due to the package of that name), but for simplicity I started with just one tex file, so it is in my main document. – ted Jul 31 '13 at 20:34
  • @egreg: I did some research, you use a tex counter, while this article explained the reasons, I do not understand what @ translates to since count expects a number after all I know. WOuld you enlighten me on its meaning in the conjunction with count? – ted Jul 31 '13 at 21:00
  • @ is just part of the counter name that @egreg is using. In the context of \makeatletter the @ is treated just like any other letter of the alphabet – A.Ellett Jul 31 '13 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.