2

I have the following enumerate list

\begin{enumerate}
    \item question 1
    \begin{enumerate}
        \item option 1
        \item option 2
        \item option 3
        \item option 4
    \end{enumerate}
\item question 2
\begin{enumerate}
    \item option 1
    \item option 2
    \item option 3
    \item option 4
\end{enumerate}

\end{enumerate}

I am thinking of randomizing both the orders of questions and options. I tried using randomlist package, and it works perfectly if I only shuffled the order of the questions as follows:

\RandomEnumerateList
{question 1
\begin{enumerate}
    \item option 1
    \item option 2
    \item option 3
    \item option 4
\end{enumerate}
}
{question 2
\begin{enumerate}
    \item option 1
    \item option 2
    \item option 3
    \item option 4
\end{enumerate}
}

But it seems not to work when putting another \RandomEnumerateList in a \RandomEnumerateList. Is there any way I can tweak my current script to shuffle both the orders of questions and options at the same time?

  • Somewhat related: https://tex.stackexchange.com/questions/346260/display-item-list-in-sequential-and-random-without-repetition-order and https://tex.stackexchange.com/questions/432272/how-to-randomise-the-order-of-macros – John Kormylo Mar 02 '23 at 18:41

1 Answers1

0

After a quick try with randomlist, I don’t know whether it’s possible to nest lists with it. Here is a quick proof-of-concept to do that with LuaLaTeX. After copying randenum.lua and randenum.sty within your project directory, the following document.tex should give the expected result:

\documentclass{scrartcl}

\usepackage{randenum}

\begin{document}

\begin{randenum} \item question 1 \begin{randenum} \item option 1 \item option 2 \item option 3 \item option 4 \end{randenum}

\item question 2
\begin{randenum}
    \item option 1
    \item option 2
    \item option 3
    \item option 4
\end{randenum}

\end{randenum}

\end{document}

Then compile with LuaLaTeX: lualatex document

Caution: there are some caveats with the approach I took:

  • \begin{randenum} and \end{randenum} must be on their own line;
  • the randenum environment can’t be easily wrapped within another environment.
jperon
  • 109
  • 1
  • 7