4

I have something like:

\pgfmathsetmacro{\radius}{2}

and inside a \foreach I'm trying to define a new value for \radius to be half the size of the previous but using

\pgfmathsetmacro\radius{\radius/2}

isn't working...

Any sugestions on how to define a value recursively?

Thanks!

  • I assume you have to expand the old value first, but without seeing any code... – user31729 Sep 7 '16 at 13:04
  • A complete example of what you're doing would be nice, there might well be some other way of solving it. – Torbjørn T. Sep 7 '16 at 13:04
  • The \foreach macro supports the key remember which can be handy in this case; an example would be very useful. – egreg Sep 7 '16 at 13:32
7

Inside a foreach the code is scoped which means when one spin is completed the value returns to its original value. You can basically do a global let

\pgfmathparse{\radius/2}
\global\let\radius=\pgfmathresult

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.