Sign up ×
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.

I am trying to generate fractals using affine transformations. I need to generate a random number in the interval (0,1), and depending on the value of this random number choose a function to calculate the coordinates of the point that I'll plot.

But the compiler is reporting an error I cannot figure out how to solve.

Here's a code that describes the situation.



    \draw[help lines] (0,0) grid (5,5);
% Here I generate a random number
% I store the random number generated in memory 

        \node[red] at (5*rnd,5*rnd){\footnotesize\aleatorio};
        \node[blue] at (5*rnd,5*rnd){\footnotesize\aleatorio};

When it comes to the line of the command \ifthenelse to make the decision, it gives me an error message.

I think it is because \ifnum can compare only integer numbers. To be honest, I am not sure. In any case, I need help to compare nonintegers (with decimal part) numbers and then continue...

I appreciate your help.

share|improve this question
Welcome to! If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). There is no need for manual <br/>s. – Caramdir May 5 '11 at 20:24

1 Answer 1

up vote 6 down vote accepted
\ifthenelse{\lengthtest{\aleatorio pt<0.5pt}}{true}{false}
share|improve this answer
I Thank you. It works great! – Efrain Soto May 5 '11 at 20:26

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.