[Tex/LaTex] Randomly arrange images in beamer

beamergraphics

I would like to arrange images in a beamer presentation without having to set them in a predefined position.
Is there a package or a fast way to place randomly into the beamer a given number of images?

\begin{figure}
    \includegraphics[width=0.3\linewidth]{img1}
    \includegraphics[width=0.3\linewidth]{img2}
    \includegraphics[width=0.3\linewidth]{img3}
\end{figure}

I would like to move them in the beamer and not having them on the same line.

Best Answer

You can use TikZ's nodes and rnd to randomize the position; the command \PlaceImageRnd has as mandatory argument a comma separated list of the image name files:

\PlaceImageRnd{<image-1>,<image-2>,...,<image-n>}

The line

\pgfmathsetseed{\pdfuniformdeviate 10000000}

makes each run of the code to update the locations.

The code:

\documentclass{beamer}
\usepackage{tikz}

\newcommand\PlaceImageRnd[1]{%
  \begin{tikzpicture}
  \pgfmathsetseed{\pdfuniformdeviate 10000000}
  \pgfmathparse{2.0*rnd+1.0}
  \foreach \Image in {#1}
  {
    \node at (10*rnd,6*rnd) 
      {\includegraphics[width=0.3\linewidth]{\Image}};
  }
  \end{tikzpicture}% 
}

\begin{document}

\begin{frame}
\PlaceImageRnd{example-image-a,example-image-b,example-image-c}
\end{frame} 

\end{document}

On the first run I got:

enter image description here

Related Question