It is a rather common practice that teachers prepare multiple versions of a test for the same exam in order to reduce cheating. Can \LaTeX do this? I want to design a math test with a set of parameters that are randomly chosen from a given set to create problems that have same wording but different numbers (something that online homework systems do).

Is such a thing possible with any latex package? Is it possible at all?

A basic example is: Produce 10 pages, each a with a copy of the following question

What is the sum $p+q$?

Where the program chooses and inserts $p$ randomly from the range 20 to 30 and $q$ from 50 to 60.

  • Yes, something like this should be possible. For comparison, a setup that permutes questions of an exam: tex.stackexchange.com/a/422219/117050
    – Skillmon
    Sep 16, 2019 at 21:55
  • The only problem is, that you can't output multiple PDFs. TeX can only produce one output file per run, so you'd get one PDF with each version in it and would have to split that PDF yourself (but TeX could write the pages at which you'd have to split to another file). Or you write yourself a Makefile which builds multiple versions and let the Makefile input the definitions of the variable which is to be replaced.
    – Skillmon
    Sep 16, 2019 at 21:56
  • All in all this question is too broad, in the way it is asked, which is why I voted to close it in its current form. But I can give a definite answer to the question (which is contained in my two earlier comments): Yes, this is possible, but not as multiple PDFs within one TeX run.
    – Skillmon
    Sep 16, 2019 at 22:05
  • 1
    Possible duplicate: How to create a random problem in math. I know everything you're asking for can be done with the sagetex package. You can even create an answer key as well at the same time.
    – DJP
    Sep 17, 2019 at 0:29
  • 1
    I developed my own system combining C++ code and LaTeX. I sort of lost interest due to a complete lack of employment prospects or feedback from other teachers. See elfsoft2000.com/worksheets/index.htm Sep 17, 2019 at 3:37


Browse other questions tagged .