TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Is there an environment (or macro for itemize) that shuffles all items randomly each time the pdf is generated?

share|improve this question
Although it doesn't have an answer, the example in this question might be of some help: Problem randomizing answers in eqexam. – Alan Munn Feb 3 '13 at 18:43

FWIW, ConTeXt supports this out of the box. Simply add the random key to \startitemize. (In ConTeXt, \startitemize[n] is equivalent to \begin{enumerate} of LaTeX).

  \startitem One \stopitem
  \startitem Two \stopitem
  \startitem Three \stopitem
  \startitem Four \stopitem
  \startitem Five \stopitem
  \startitem Six \stopitem

which gives:

enter image description here

The random seed is stored in the tuc file so that you get the same output each time the file is compiled (otherwise, multiple compiles can lead to an infinite cycle and you may not get all the references correct). So you need to delete the tuc file to change the random seed, and hence get a different output.

share|improve this answer
You can also set the random seed without deleting the tuc file. See: wiki.contextgarden.net/Random – Dave Jarvis Oct 5 '13 at 18:44

As the usual implementation of \begin{list} \item ... \item ... \item ... \end{list} doesn't read or save the actual text of the items, some out-of-my-league hacking needs to be done to save then permute list items if you want the same interface.

I asked a similar question on the pgf-users mailing list several years ago. Here is Mark Wibrow's answer for randomizing a PGF list of the form declared by \pgfmathdeclarelist. I've dropped this snippet into my exam files ever since.



                \expandafter\edef\csname pgfmath@list@\pgfmath@list@name 
                \advance\c@pgfmath@counta by1\relax% 
                \pgfutil@namedef{pgfmath@list@\pgfmath@list@name @\the\c@pgfmath@counta}{#1}% 







\begin{tikzpicture}[every node/.style={circle, draw}] 

\foreach \i in {1,...,\l}{ 
        \node at (0,-\i) (\x-1) {\x}; 


\foreach \i in {1,...,\l}{ 
        \node at (7.5,-\i) (\x-2) {\x}; 

\foreach \i in {1,...,\l}{ 
        \draw [->] (\x-1) -- (\x-2); 

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.