I have the following problem: Into a \pgfdeclareshape I have the following code for a saved dimension:

  \pgf@x=\pgfkeysvalueof{/tikz/longitud salidas}\unidad@medicion

Then, when I try to use in:

\foreach \n in {1,...,7}{
      \@tempdima=2\x@colect % \sep@sal
        -\x@colect + 0.5\@tempdima + (\n-1)*\@tempdima

I get the error: ! Undefined control sequence.

The problem is due to \long@sal, I'm sure. Please, someone can help me?

  • 1
    Every loop cycle of \foreach is executed in a group, so nothing local is persistent between iterations. You have different choices, for example: define things globally, or use a loop from another package. – Kpym Mar 19 at 19:56
  • In addition to what @Kpym is saying you could smuggle the macro out of the group: tex.stackexchange.com/a/470979/121799 – marmot Mar 19 at 20:15
  • @Kpym I also used \loop \repeat tex and it doesn't work. Defining globaly \long@sal neither works because its value can't be modified into \pgfdeclareshape. – aguivald Mar 19 at 22:22
  • @marmot Thanks. I'm afraid that the referred code is so tricky for me than I'll be more than a while to digest it. What's more, I think that I am not be able to understand it. – aguivald Mar 19 at 22:33
  • 1
    @marmot and @Kpym I found the solution. It was easier than it seemed: the problem was solved adding \newdimen\long@sal before \pfgdeclareshape. – aguivald Mar 20 at 4:43

At the end, the solution is easy. Including \newdimen\long@sal before \pfgdeclareshape, and it properly works.

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.