This questtion is extending the already answered question: Randomly arrange images in beamer. Since the person posting the correct answer seems no longer active I am creating a new question.

The question is: Is there a way to make nodes not to overlap one another, yet still randomly distributed on the slide?

I have tried to find a structure to store the nodes to and then check for the overlaps and try to move them or shift them, but I did not find the right data structures. Starting to think this might not be possible.


Modifying https://tex.stackexchange.com/a/87518/190633 :



%    \draw (0,0) rectangle (#1,#2);
    \foreach \i in {1,...,#4}{
        \foreach \element [count=\i] in \xlist{
            \pgfmathsetmacro\checkdistance{ sqrt( ({\xlist}[\j]-(\x))^2 + ({\ylist}[\j]-(\y))^2 ) }
            \ifdim\checkdistance pt<\diameter pt
            \node at (\x,\y) {\includegraphics[width=1cm]{example-image}};
%            \draw [red, thick] (\x,\y) circle [radius=#3];





enter image description here

  • I would accept it as an answer, but it does need fixed size to be passed to the macro and does not take the array of images as an input. The latter can be solved quite easily, but I did not manage to solve the first one. – Croolman Jun 12 '19 at 17:12

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.