I'd like to make LaTeX pick one image file randomly from a series of eight images, and include it. I found that ''lcg'' package can generate random numbers:
\usepackage{lcg}
\reinitrand[counter=sec,first=1,last=8]
So i expected this line to include one of the images randomly:
\includegraphics[width=0.6cm]{excl0\rand\arabic{sec}c.png}
Where the file names are excl01c.png, excl02c.png, and so on. The result was not like i have imagined, i got an error message:
Runaway definition?
->excl0\cr@nd = 126\advance \cr@nd \inputlineno \multiply \cr@nd 3\advance \ETC
.
! TeX capacity exceeded, sorry [main memory size=3000000].
<argument> Random number generator initiali
zed to \the \cr@nd
My question is what is the reason of this kind of error, and how to fix it, how to make LaTeX choose an image file randomly?

\randbefore\includegraphics– egreg Sep 16 '12 at 09:58