For modelling a list of questions with yes/no answers I wanted to define an environment where I can setup a question with a command: \clO for an option that's not applicable and \clX for those that are applicable.

Based on the solution in How can I lay out multiple choice answers as a matrix with exam? I wanted to use tabularx instead of tabular, as the right column has to be multiline and fill up all the space.

Everything works as planned until I want to finally set one element as \CorrectChoice in the \clO or \clX command, resulting in a weird error message: mwe.tex:41 Something's wrong--perhaps a missing \item. \end{choicelist}





    & \begin{varwidth}{\textwidth}\begin{checkboxes}\choice\end{checkboxes}\end{varwidth}
    & #1\\
    & \begin{varwidth}{\textwidth}\begin{checkboxes}\choice\end{checkboxes}\end{varwidth}
    & #1\\
    applicable & not applicable & \\

    Lorem ipsum dolor sit amet?

        \clO{This is a multiline description to be answered, so we have to use a long text to ensure we can see a line break in the example.}
  • It's not a problem of tabularx: if I change tabularx to tabular, the problem is the same and is due to the fact that a group ends up straddling two alignment cells, which is not allowed. – egreg May 25 '15 at 15:47
  • What is meant by 'group' here? The command? or the start & end of the environment? 'alignment cells' are the table columns? Why does /CorrectChoice trigger that problem and /choice does not? How could I workaround this? – hoeni May 25 '15 at 18:53
  • The command \CorrectChoice issues a \begingroup command, whose matching \endgroup` occurs much later, at \end{checkboxes}, which happens in another alignment cell; this is not allowed. The \choice command doesn't issue this \begingroup command. – egreg May 25 '15 at 19:56
  • I also tried putting both ends together in a command with no success. So I really will have to paste those two checkboxes manually over and over again for each question? (...but I'll start the long way of trying to understand what happens inside exam.cls :-)) – hoeni May 30 '15 at 9:38
  • @hoeni \begin{checkboxes}\CorrectChoice\end{checkboxes} should be \begin{checkboxes}\CorrectChoice\ \end{checkboxes} – Maarten Dhondt Jun 14 '15 at 15:11

I just had the same problem and redefined \choice and \CorrectChoice, so that I can use them inside a tabular environment and without adding checkboxes environment.


\newcommand{\CorrectChoice}{% true
\newcommand{\choice}{% false
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.