# [OS X TeX] Counters, Random Numbers and Exam.cls

Ross Moore ross at ics.mq.edu.au
Mon Aug 6 16:17:22 EDT 2007

```On 07/08/2007, at 4:04 AM, Matthew Inglis wrote:

> Hi all,
>
> I'm using Jason Alexander's exam.cls (sometimes called examdesign)
> package to generate scripts for participants in an experiment I'm
> running. I need each participant's stimuli to be generated randomly.
> For this I'd normally use the lcg package. However, because of the way
> exam.cls works, although randomly generated, the stimuli come out the
> same for each participant.
>
> So, my question is this: is it possible to create a counter whose name
> includes another counter?
> [i.e. a first guess might be something like
> \usepackage[first=1,last=26,counter=letter\arabic{version}]{lcg}

Have you tried this?  What happens?

Another way which certainly should work is:

\edef\letterversion{letter\arabic{version}}
\usepackage[first=1,last=26,counter=\letterversion]{lcg}

You must use  \usepackage within the preamble, so you will
need some coding there that assigns a different value to the
{version}  counter there, to create the different versions.

> (I was hoping this would generate a different counter for each value
> of the counter "version". It doesn't work, but maybe there is a
> different syntax?)]

But I really don't understand what you are trying to do.
Why do you need different counters for each instance of the
document?

Surely you only need a different "seed" for the generator,
with each run of the document for the different students.
These seeds can be a simple sequence:  1, 2, 3, 4, ...
or they can be some (random) sequence that has been
pre-generated and stored in a file, which can be read by LaTeX.

As I understand the way the coding in  lcg.sty   works, is that
with  \usepackage[...]{lcg}  you specify a name for the counter,
and a range for the integer values that it will contain.

There is nothing random until you "seed" the generator.
Then each call to  \rand  generates a new (pseudo-)random
number, stored in the named counter.

The purpose of the seed is so that you can regenerate the same
sequence of "random" numbers, with later runs of the same
document instance, or with a different document (e.g., for
the solutions to your exams, for each student).

>
> Alternatively, is there a way of deleting counters mid-compile, so
> that when exam.cls parses the file with a different value of
> "version", the counters used by lcg no longer exist?

Why does existence of the counter matter?
Surely the only thing that is important is the number that the counter
holds, which is determined first by the seed, then by each call to
\rand ?

>
> Alternatively, is there some other way of getting lcg to generate
> different random numbers for each version of a script generated by
> exam.cls?
>
> Thanks in advance for any help,

Hope this helps,

Ross

>
> Matthew
>
>
> --
> Matthew Inglis
> Learning Sciences Research Institute
> University of Nottingham
>
> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
> TeX FAQ: http://www.tex.ac.uk/faq
> List Archive: http://tug.org/pipermail/macostex-archives/
> List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/
>
>