In some codes I encountered some \z command, for example:


from this question: Generating random numbers without repetitions. What exactly does it mean?

  • It's simply the name of a macro. – Gonzalo Medina Jan 30 '15 at 18:30
  • just a macro? but if you look at the accepted answer of the linked question, there is no definition of \z... and the code, cut-and-pasted on my editor, works – user126154 Jan 30 '15 at 18:33
  • \pgfmathrandomitem internally makes the necessary definition. – Gonzalo Medina Jan 30 '15 at 18:34
  • The answer is not accepted, as there's no check by it, @user126154. I'd strongly suggest you mark it as such – hd1 Jan 30 '15 at 22:08
  • @hd1 The user was referring to 'the accepted answer of the linked question', and the linked question not only has an accepted answer. It isn't the OP's question in any case, so they couldn't accept an answer if they wanted to. – cfr Jan 31 '15 at 2:23

It's nothing more than a standard macro. Instead of \z you could have used \xxxyyy or any other valid macro name.

The line


simply selects an item from the mylist list and stores it in the macro \z.



shows the item stored in \z and removes it from the list.

  • so the \z\prunelist{mylist} just prune the listo fo the "macro" \z? – user126154 Jan 30 '15 at 18:34
  • @user126154 \z\prunelist{mylist} removes the item stored in \z from the list. – Gonzalo Medina Jan 30 '15 at 18:38
  • Ok, now I cut-and-pasted the code, but then I try to use the macro \z elsewhere just by adding \z to some test place and the result is not what I expected – user126154 Jan 30 '15 at 18:47
  • if I type for instance \pgfmathrandomitem\z{mylist}\z\prunelist{mylist}\z then the result of the last \z is the successor, in the list order, of the firs \z – user126154 Jan 30 '15 at 18:48
  • i would like indeed store a random element of mylist in a macro that can be used elsewhere – user126154 Jan 30 '15 at 18:51

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.