problems with \forloop and \foreach (Support #585)
Description
Dear Community, I am preparing an AMC test importing questions from a unique directory through some \element{all}{\input{q1.tex}} commands. My questions are named q1.tex q2.tez q3.tex q4.tex I would like to import all of them in a unique way through a loop with a counter.
I tried \forloop and pgf command \foreach but none of them is working. The first one works if the loop is defined inside the \element{all}. In this way I have 4 questions which cannont be shuffled (if I understood correctly elements of group are shuffled but different questions inside a unique element are not shuffled). I try to define \forloop outside the \element command but it does not work. It seems that the element command produces conflicts with loops.
Any idea?
Thanks in advance,
Giovanni
History
Updated by Alexis Bienvenüe about 6 years ago
- Tracker changed from Bug to Support
Updated by Alexis Bienvenüe about 6 years ago
The whole code inside the \element
call is added as-is in the group. It is only called when displaying elements, so that at this time the question
counter equals 4 for all elements…
Maybe you can try something like that:
\newcommand\addsource[1]{ \element{all}{\input{./q#1.tex}} } \newcount\nsource\nsource=1 \loop \expandafter\addsource\expandafter{\the\nsource} \ifnum\nsource<4\advance\nsource by 1\repeat
- Status changed from New to Feedback