Is there an environment (or macro for itemize) that shuffles all items randomly each time the pdf is generated?
[Tex/LaTex] Random shuffle itemize
#enumerateenvironmentslistsrandom numbers
Related Solutions
A regular description
environment does this for you. It typesets its argument in bold, although this can be modified using the enumitem
:
\documentclass{article}
\begin{document}
\begin{description}
\item[Blogiddy Bloop] --- A bloggidy bloop is a thing that does stuff.
\item[Apwitchik] --- A apwitchik is a thing that does other stuff.
\item[Deddydoo] --- A Deddydoo does all the stuff a Bloggiddy Bloop and an Apwitchik do, but even more.
\end{description}
\end{document}
If you want to add the ---
style, you could create a command (say) \descitem[<item>]
to include this by default. <item>
is optional, and defaults to Item
:
\documentclass{article}
\newcommand{\descitem}[1][Item]{\item[#1~---]}%
\begin{document}
\begin{description}
\descitem[Blogiddy Bloop] A bloggidy bloop is a thing that does stuff.
\descitem[Apwitchik] A apwitchik is a thing that does other stuff.
\descitem[Deddydoo] A Deddydoo does all the stuff a Bloggiddy Bloop and an Apwitchik do, but even more.
\end{description}
\end{document}
You could use TikZ nodes and pgf made random numbers, for example:
\documentclass{article}
\usepackage{tikz}
\usepackage[T1]{fontenc}
\usepackage[ocr-a]{ocr}
\usetikzlibrary{chains,positioning}
\usepackage{datetime}
\pgfmathparse{\year+\time+\currenthour+\currentminute*\currentsecond}
\pgfmathsetseed{\pgfmathresult}
\begin{document}
\begin{tikzpicture}[start chain=1 going right,node distance=-0.4pt]
\foreach \x in {1,2,...,15} {
\node (\x) [draw,on chain=1] {\pgfmathparse{random(0,9)}\ocr{\pgfmathresult}};}
\node [above of=1,anchor=south west,yshift=2ex,xshift=-2.4ex]
{Do not write in this area};
\node [below of=1,anchor=north west,yshift=-2ex,xshift=-2.4ex]
{\scshape Each document must have a unique serial number};
\end{tikzpicture}
\end{document}
The output, using ocr-a
numbers, as Mico advised in his comment below:
To get different numbers for each compilation, you could initialize the random number generator yourself by
\pgfmathsetseed{<integer>}
By default, it's the value of \time
*\year
. So it would't change during each compilation, so I used the datetime
package to use also minutes and seconds for calculating the seed. So the random values should change each second. You could also use values or counters in your .aux
file instead.
You can get the ocr-a
font from CTAN: http://ctan.org/pkg/ocr-a.
If you don't manage to install it, a quick workaround: you could load the mf
and tfm
files (for example from here), put them into your document directory and run (with fontenc
and ocr
as above) - it worked for me.
Best Answer
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).which gives:
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.