TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a circle of elements with some randomness to it. I want to predefined the coordinates to create complicated element. I am using this:

  \shade [ball color=red] (#1,#2) circle (4 pt);

and this:

  \foreach \ang in {0,90,...,270}{
    \elm{{\r*cos(\ang) + \dx},{\r*sin(\ang)+\dy}}

All I get is a blank sheet of paper without any figure. How can do this correctly?

share|improve this question

It might be more beneficial to use \pgfmathsetlengthmacro for this. Currently it takes 2 meters for the \r variable since the default is centimeters.

  \foreach \ang in {0,90,...,270}{
    \pgfmathsetlengthmacro{\dx}{rand*2 cm}
    \pgfmathsetlengthmacro{\dy}{rand*2 cm}
    \shade [ball color=red] ({\r*cos(\ang) + \dx},{\r*sin(\ang) + \dy}) circle (4 pt);

Also if I am not wrong you are passing only one argument to \elm where you have two defined. I removed it to make it more concise.

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.