Discussion:
Random enumeration in LaTex
(too old to reply)
TCL
2010-05-13 20:00:32 UTC
Permalink
Is it possible to tell LaTex to randomly enumerate a list?

Like


\begin{enumerate}[random]


\item .....
\item ....


\end{enumerate} [random]


This should come in handy for teachers making up multiple choice
exams.
Marco Daniel
2010-05-13 20:59:23 UTC
Permalink
Hi,

you can combine the list environment with the package lcg.

regards
Marco
Post by TCL
Is it possible to tell LaTex to randomly enumerate a list?
Like
\begin{enumerate}[random]
\item .....
\item ....
\end{enumerate} [random]
This should come in handy for teachers making up multiple choice
exams.
TCL
2010-05-13 22:56:09 UTC
Permalink
Post by Marco Daniel
Hi,
you can combine the list environment with the package lcg.
regards
Marco
Post by TCL
Is it possible to tell LaTex to randomly enumerate a list?
Like
\begin{enumerate}[random]
\item .....
\item ....
\end{enumerate} [random]
This should come in handy for teachers making up multiple choice
exams.- Hide quoted text -
- Show quoted text -
I installed the package. But what is the command? The command I show
above \begin{enumerate}[random]
does not work.

Thank you very much.
Martin Heller
2010-05-13 23:32:06 UTC
Permalink
Post by TCL
Post by TCL
This should come in handy for teachers making up multiple choice
exams.- Hide quoted text -
There are multiple packages for creating exams on ctan
http://www.ctan.org/pkg/examdesign
http://www.ctan.org/pkg/exam
http://www.ctan.org/pkg/exams
http://www.ctan.org/pkg/exerquiz

the latter is part of the AcroTeX education bundle
http://ctan.org/pkg/acrotex
that allows you to make interactive tests, games and quizzes.
Post by TCL
I installed the package. But what is the command? The command I show
above \begin{enumerate}[random]
does not work.
Thank you very much.
I think you need to do something along the lines of:

\documentclass{article}
\usepackage{lcg}

\begin{document}

\reinitrand[first=1, last=3, counter=die]
\begin{itemize}
\item[\rand\arabic{die}.] Foo.
\item[\rand\arabic{die}.] Bar.
\item[\rand\arabic{die}.] Baz.
\end{itemize}

\end{document}
TCL
2010-05-14 14:47:27 UTC
Permalink
Post by TCL
Post by TCL
This should come in handy for teachers making up multiple choice
exams.- Hide quoted text -
There are multiple packages for creating exams on ctanhttp://www.ctan.org/pkg/examdesignhttp://www.ctan.org/pkg/examhttp://www.ctan.org/pkg/examshttp://www.ctan.org/pkg/exerquiz
the latter is part of the AcroTeX education bundlehttp://ctan.org/pkg/acrotex
that allows you to make interactive tests, games and quizzes.
Post by TCL
I installed the package. But what is the command? The command I show
above  \begin{enumerate}[random]
does not work.
Thank you very much.
\documentclass{article}
\usepackage{lcg}
\begin{document}
\reinitrand[first=1, last=3, counter=die]
  \begin{itemize}
   \item[\rand\arabic{die}.] Foo.
   \item[\rand\arabic{die}.] Bar.
   \item[\rand\arabic{die}.] Baz.
  \end{itemize}
\end{document}
This does not work. The result it produces is a random order of the
number but not the content of the number: e.g. 3. Foo 1. Bar 2.
Baz
What one intended should be e.g. 1. Bar 2. Baz 3. Foo
m***@mendelu.cz
2010-05-15 00:10:22 UTC
Permalink
Post by TCL
This should come in handy for teachers making up multiple choice
exams.- Hide quoted text -
There are multiple packages for creating exams on ctanhttp://www.ctan.org/pkg/examdesignhttp://www.ctan.org/pkg/examhttp://www.ctan.org/pkg/examshttp://www.ctan.org/pkg/exerquiz
the latter is part of the AcroTeX education bundlehttp://ctan.org/pkg/acrotex
that allows you to make interactive tests, games and quizzes.
AcroTeX education bundle has also forpaper option and allowrandomize -
this option makes what you want. Just try it.

If you do not want to use this bundle, you need something like this
(use lualatex to compile):

\documentclass{article}

\begin{document}

\def\saveitem#1#2{\expandafter\def\csname option#1\endcsname{#2}}
\def\useitem{\item \def\temp{\directlua{tex.print(math.random(1,3))}}
\csname option\temp \endcsname}
\begin{itemize}
\saveitem1{first}
\saveitem2{second}
\saveitem3{third}
\useitem
\useitem
\useitem
\end{itemize}

\end{document}


Far from perfect, since the same answer may appear multiple times -
you need a random permuation rather than random numbers. I have seen a
similar example with luatex, but cannot find it just now. Needs
programming, but generaly this is the way.


Robert
José Carlos Santos
2010-05-14 06:50:04 UTC
Permalink
Post by TCL
I installed the package. But what is the command? The command I show
above \begin{enumerate}[random]
does not work.
Try this:

\documentclass{article}
\usepackage[first=1,last=6]{lcg}
\begin{document}
\begin{enumerate}
\item[\rand\arabic{rand}.] Something
\item[\rand\arabic{rand}.] Something else
\item[\rand\arabic{rand}.] And still something else
\end{enumerate}
\end{document}

Best regards,

Jose Carlos Santos
TCL
2010-05-14 14:50:28 UTC
Permalink
Post by Martin Heller
Post by TCL
I installed the package. But what is the command? The command I show
above  \begin{enumerate}[random]
does not work.
\documentclass{article}
\usepackage[first=1,last=6]{lcg}
\begin{document}
\begin{enumerate}
\item[\rand\arabic{rand}.] Something
\item[\rand\arabic{rand}.] Something else
\item[\rand\arabic{rand}.] And still something else
\end{enumerate}
\end{document}
Best regards,
Jose Carlos Santos
This does not work. The result it produces is a random order of the
number but not the content of the number: e.g. 5. Something 1.
Something else 2. And still something else
What one intended should be e.g. 1. Something else 2. And still
something else 3. Something
Oliver Corff
2010-05-15 07:34:28 UTC
Permalink
TCL <***@cox.net> wrote:
: On May 14, 2:50 am, José Carlos Santos <***@fc.up.pt> wrote:
: > On 13-05-2010 23:56, TCL wrote:
: >
: > > I installed the package. But what is the command? The command I show
: > > above  \begin{enumerate}[random]
: > > does not work.
: >
: > Try this:
: >
: > \documentclass{article}
: > \usepackage[first=1,last=6]{lcg}
: > \begin{document}
: > \begin{enumerate}
: > \item[\rand\arabic{rand}.] Something
: > \item[\rand\arabic{rand}.] Something else
: > \item[\rand\arabic{rand}.] And still something else
: > \end{enumerate}
: > \end{document}
: >
: > Best regards,
: >
: > Jose Carlos Santos

: This does not work. The result it produces is a random order of the
: number but not the content of the number: e.g. 5. Something 1.
: Something else 2. And still something else
: What one intended should be e.g. 1. Something else 2. And still
: something else 3. Something

Hi,

I just think of a possible solution which helps you randomize the
/order/ of your items rather than their enumeration.

The following code is untested and certainly contains errors, but
perhaps you get the idea.

You should separate answers and numbering. Store the answers in a
structure separate from your itemized list.

\documentclass{article}
\usepackage[first=1,last=5]{lcg}
\newcommand{\MyChoice}[1]{\ifcase #1
\or Some item
\or Another item
\or Yet another item
\or Again another item
\or A fifth item
\fi}

\begin{document}
\begin{enumerate}
\item \MyChoice{\rand\arabic{rand}}
\item \MyChoice{\rand\arabic{rand}}
\item \MyChoice{\rand\arabic{rand}}
\item \MyChoice{\rand\arabic{rand}}
\item \MyChoice{\rand\arabic{rand}}
\end{enumerate}
\end{document}

For more multiple-choice questions, you can \renewcommand{\MyChoice}.

Hth,

Oliver.
--
Dr. Oliver Corff e-mail: ***@zedat.fu-berlin.de
TCL
2010-05-15 13:18:11 UTC
Permalink
Post by Oliver Corff
: >
: > > I installed the package. But what is the command? The command I show
: > > above  \begin{enumerate}[random]
: > > does not work.
: >
: >
: > \documentclass{article}
: > \usepackage[first=1,last=6]{lcg}
: > \begin{document}
: > \begin{enumerate}
: > \item[\rand\arabic{rand}.] Something
: > \item[\rand\arabic{rand}.] Something else
: > \item[\rand\arabic{rand}.] And still something else
: > \end{enumerate}
: > \end{document}
: >
: > Best regards,
: >
: > Jose Carlos Santos
: This does not work. The result it produces is a random order of the
: number but not the content of the number: e.g.  5. Something   1.
: Something else  2. And still something else
: What one intended should be e.g.  1. Something else   2. And still
: something else   3. Something
Hi,
I just think of a possible solution which helps you randomize the
/order/ of your items rather than their enumeration.
The following code is untested and certainly contains errors, but
perhaps you get the idea.
You should separate answers and numbering. Store the answers in a
structure separate from your itemized list.
\documentclass{article}
\usepackage[first=1,last=5]{lcg}
\newcommand{\MyChoice}[1]{\ifcase #1
        \or Some item
        \or Another item
        \or Yet another item
        \or Again another item
        \or A fifth item
    \fi}
\begin{document}
\begin{enumerate}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
\end{enumerate}
\end{document}
For more multiple-choice questions, you can \renewcommand{\MyChoice}.
Hth,
Oliver.
--
No. That does not work. It produces the following:

1. =5532
2.
3.
4.
5.

The 5532 changes every time I run it -- that is due to randomness. But
of course this does not help.
m***@mendelu.cz
2010-05-15 16:00:27 UTC
Permalink
Post by TCL
Post by Oliver Corff
: >
: > > I installed the package. But what is the command? The command I show
: > > above  \begin{enumerate}[random]
: > > does not work.
: >
: >
: > \documentclass{article}
: > \usepackage[first=1,last=6]{lcg}
: > \begin{document}
: > \begin{enumerate}
: > \item[\rand\arabic{rand}.] Something
: > \item[\rand\arabic{rand}.] Something else
: > \item[\rand\arabic{rand}.] And still something else
: > \end{enumerate}
: > \end{document}
: >
: > Best regards,
: >
: > Jose Carlos Santos
: This does not work. The result it produces is a random order of the
: number but not the content of the number: e.g.  5. Something   1.
: Something else  2. And still something else
: What one intended should be e.g.  1. Something else   2. And still
: something else   3. Something
Hi,
I just think of a possible solution which helps you randomize the
/order/ of your items rather than their enumeration.
The following code is untested and certainly contains errors, but
perhaps you get the idea.
You should separate answers and numbering. Store the answers in a
structure separate from your itemized list.
\documentclass{article}
\usepackage[first=1,last=5]{lcg}
\newcommand{\MyChoice}[1]{\ifcase #1
        \or Some item
        \or Another item
        \or Yet another item
        \or Again another item
        \or A fifth item
    \fi}
\begin{document}
\begin{enumerate}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
    \item \MyChoice{\rand\arabic{rand}}
\end{enumerate}
\end{document}
For more multiple-choice questions, you can \renewcommand{\MyChoice}.
Hth,
Oliver.
--
1. =5532
2.
3.
4.
5.
The 5532 changes every time I run it -- that is due to randomness. But
of course this does not help.
For solution to your problem look at http://www.math.uakron.edu/~dpstory/acrotex/aeb_man.pdf
page 115 (randomizing the multiple choices). Does this help.

Robert
Oliver Corff
2010-05-15 16:58:14 UTC
Permalink
: > Hi,
: >
: > I just think of a possible solution which helps you randomize the
: > /order/ of your items rather than their enumeration.
: >

As I said:

: > The following code is untested and certainly contains errors, but
: > perhaps you get the idea.
: >
: > You should separate answers and numbering. Store the answers in a
: > structure separate from your itemized list.
: >
: > \documentclass{article}
: > \usepackage[first=1,last=5]{lcg}
: > \newcommand{\MyChoice}[1]{\ifcase #1
: >         \or Some item
: >         \or Another item
: >         \or Yet another item
: >         \or Again another item
: >         \or A fifth item
: >     \fi}
: >
: > \begin{document}
: > \begin{enumerate}
: >     \item \MyChoice{\rand\arabic{rand}}
: >     \item \MyChoice{\rand\arabic{rand}}
: >     \item \MyChoice{\rand\arabic{rand}}
: >     \item \MyChoice{\rand\arabic{rand}}
: >     \item \MyChoice{\rand\arabic{rand}}
: > \end{enumerate}
: > \end{document}
: >

: No. That does not work. It produces the following:

: 1. =5532
: 2.
: 3.
: 4.
: 5.

: The 5532 changes every time I run it -- that is due to randomness. But
: of course this does not help.

As I said, the code is untested. Change it as follows:
: >     \item \MyChoice{\rand\arabic{rand}}
becomes:
\item \rand\MyChoice{\arabic{rand}}

The argument to \MyChoice must be a plain digit, it was my mistake
to put the \rand call into the argument, too. If you call \rand before
invoking \MyChoice, the example works.

Hth,
Oliver.
--
Dr. Oliver Corff e-mail: ***@zedat.fu-berlin.de
m***@mendelu.cz
2010-05-15 18:12:38 UTC
Permalink
Post by Oliver Corff
The argument to \MyChoice must be a plain digit, it was my mistake
to put the \rand call into the argument, too. If you call \rand before
invoking \MyChoice, the example works.
Hi, it compiles but does not work properly - some items are listed two
times and some are missing.

Robert


btw: I tested this:

\documentclass{article}
\usepackage[first=1,last=5]{lcg}
\newcommand{\MyChoice}[1]{\ifcase #1
\or Some item
\or Another item
\or Yet another item
\or Again another item
\or A fifth item
\fi}

\begin{document}
\begin{enumerate}
\item \rand\MyChoice{\arabic{rand}}
\item \rand\MyChoice{\arabic{rand}}
\item \rand\MyChoice{\arabic{rand}}
\item \rand\MyChoice{\arabic{rand}}
\item \rand\MyChoice{\arabic{rand}}
\end{enumerate}
\end{document}
Post by Oliver Corff
Hth,
Oliver.
--
Oliver Corff
2010-05-15 18:51:21 UTC
Permalink
***@mendelu.cz <***@mendelu.cz> wrote:
: On 15 kv?, 18:58, Oliver Corff <***@samoa.zedat.fu-berlin.de> wrote:
: >
: > The argument to \MyChoice must be a plain digit, it was my mistake
: > to put the \rand call into the argument, too. If you call \rand before
: > invoking \MyChoice, the example works.

: Hi, it compiles but does not work properly - some items are listed two
: times and some are missing.

Sure. The example lacks a mechanism to check which numbers have been called
before, and it doesn't check which ones it failed to call. The example
was solely intended to demonstrate how to separate item numbering from
the order of items. Same with the luatex example.

So it is perhaps best not to re-invent the wheel but to use proven
solutions as in the packages you recommended.

Oliver.
--
Dr. Oliver Corff e-mail: ***@zedat.fu-berlin.de
Loading...