I want to define a set of conditionals using newif in a loop. The loop variable should become part of the conditional's name. However, I'm running into trouble when trying to set the conditional and when defining multiple conditionals in one loop.

When I try to define a second conditional using the same code structure, I end up getting the following error: Missing \endcsname inserted.. The same happens when trying to set the if conditional.



  \advance\count@ 1
  \expandafter\newif\csname ifrst@onlyheight\@Alph\count@\endcsname%
  %\expandafter\newif\csname ifrst@onlywidth\@Alph\count@\endcsname%
  %\csname rst@onlyheight\@Alph\count@ true\endcsname
  \csname rst@onlyheightAtrue\endcsname


More code here.


\count@ is set during the processing of \newif:

% latex.ltx, line 910:
  \count@\escapechar \escapechar\m@ne

Use \@tempcnta instead.

A different loop:


\int_step_inline:nnnn { 1 } { 1 } { 5 }
  \exp_args:Nc \newif { ifrst@onlyheight \int_to_Alph:n { #1 } }
  \exp_args:Nc \newif { ifrst@onlywidth \int_to_Alph:n { #1 } }
  \use:c { rst@onlywidth \int_to_Alph:n { #1 } true }


\meaning\ifrst@onlyheightA \\
\meaning\ifrst@onlyheightB \\
\meaning\ifrst@onlyheightC \\
\meaning\ifrst@onlyheightD \\
\meaning\ifrst@onlyheightE \\
\meaning\ifrst@onlywidthA \\
\meaning\ifrst@onlywidthB \\
\meaning\ifrst@onlywidthC \\
\meaning\ifrst@onlywidthD \\

enter image description here

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.