I'm a new user on the Exchange, but not as new to LaTeX, so I hope I'm able to give some context to this problem.

I have two machines. I'm working on Debian 9.11 (stretch) on both machines; both machines are 64-bit, and have TeXLive 2019 and TeXStudio installed on both. When installing on both machines, I used the install-tl script provided by tug.org, and had symbolic links/etc use the default settings on both machines. In principle (in my mind), the setup on both machines should be virtually identical, though they must not be, because of the error I'm getting.

I am reworking some of my exams to be more randomized to make some of the questions more reusable, so I'm using both pythontex and mcexam. The Python stuff works fine; it's the mcexam stuff that is presenting the issue.

On my desktop, I can compile and randomize with no issue at all, provided I remember to close out environments and lists like I'm supposed to. I can randomize questions and answers, set seeds, change display type, write the R file, the whole nine yards.

On my laptop, however, with the same exact options set, I get an error when I set "randomizeanswers=true". The error is an "Incomplete \ifx" error, and ignores all text after the end of the mcquestions environment; the pdf doesn't compile, and I don't have a test to use. Based on what I found in this similar question: LaTeX file using mcexam package compiles on OSX but not on Windows , I had the inspiration to turn "randomizeanswers=false", and now it will compile on both machines the way I expect. I've tried messing with the other package options, too, and they don't seem to have any problem; it's something to do with how the package is trying to randomize the answer choices on my laptop that is different than on my desktop.

The trouble is... I'm at quite a loss as to how to figure out what that problem is, and fix it. The package documentation doesn't give guidance about the core mechanics about how this option does what it's doing, and while I can open the mcexam.sty file and have tried to figure out the issue, I'm not yet at a level that I can read the fundamental TeX language and diagnose the problem, myself.

Anyone willing to lend a hand?

For a MWE, I'll use a pair of the questions in the mcexam_example.tex file, since they give this error on the laptop if randomizeanswers=true, and compile properly if =false:



% Packages used for special things

% Set headers and footers
\rfoot{Page \thepage\ of \pageref{LastPage}}

% Ensure each question+answers is printed entirely on the same page.



\question What is the color of the sky?

          \answer[correct] blue
          \answer green
          \answer red
          \answer yellow
          \answer none of the above

\question Which figure is a square?
          \answer{1}{\tikz{\draw (-0.66,0)--(0.66,0)--(0,1)--cycle;}}& 
          \answer{2}{\tikz{\draw (0,0)--(2,0)--(2,1)--(0,1)--cycle;}}& 
          \answer[correct]{3}{\tikz{\draw (0,0)--(1,0)--(1,1)--(0,1)--cycle;}}& 
          \answer{4}{\tikz{\draw (0,0) circle[radius=0.5];}}\\



Thanks for any help you can offer!

  • Welcome to TeX.SX! You should never enable symbolic links when installing on Debian with install-tl.
    – egreg
    Oct 3, 2019 at 13:28
  • Thanks for the welcome--is there a reason for not doing this? But even still, I'm not sure that explains the quandary, since even though I used the exact same setup on both machines, the desktop compiles as expected with the option in question turned on, and the laptop gives me the error. That's the thing I'm most trying to diagnose!
    – Wayne
    Oct 3, 2019 at 13:31
  • If you have also the Debian provided TeX Live and your pdflatex resides in /usr/bin, because you enabled creating symlinks, then it will use the Debian files, instead of the TUG ones.
    – egreg
    Oct 3, 2019 at 13:33
  • Would this explain the mixed behavior, though? As I said, it compiles with no errors regardless of the settings of the package options on the desktop, but the setting of this package option impacts whether the document compiles on the laptop. Is the symlink issue the thing that's causing the problem? Why would that be the case, if the mcexam package is from Dec 2017, and the Debian TeX in 9.11 is from Sep 2019?
    – Wayne
    Oct 3, 2019 at 13:39
  • Add \listfiles at the beginning and compare the file list you get at the end of the log file (use randomizeanswers=false so as it compiles on both machines).
    – egreg
    Oct 3, 2019 at 13:45

1 Answer 1


I also got this error yesterday, and I've fixed it myself with the following lines of changes (one addition on Line 1060 and one update on Line 1063) to the mc@randomizeAnswers@permuteall function in mcexam.sty. Hope this helps.

--- /usr/local/texlive/2019/texmf-dist/tex/latex/mcexam/mcexam.sty
+++ mcexam.sty
@@ -1055,23 +1055,24 @@

   \foreach \a in {1,...,\csuse{mc@totalNumberOfAnswersQ\q}}{
+  \numdef\@numberofpermuteanswers{\csuse{mc@totalNumberOfAnswersQ\q}}
   \foreach \v in {1,...,\mc@totalNumberOfVersions}{  
     \foreach \x in {1,...,\@numberofswaps}{
-      \pgfmathrandominteger{\r}{\x}{\csuse{mc@totalNumberOfAnswersQ\q}}
+      \pgfmathrandominteger{\r}{\x}{\@numberofpermuteanswers}
     \foreach \a in {1,...,\csuse{mc@totalNumberOfAnswersQ\q}}{
        \csxdef{mc@randomAnswerNumberV\v Q\q A\a}{\csuse{mc@answerTempnum\a}}
        \csxdef{mc@originalAnswerNumberV\v Q\q A\csuse{mc@answerTempnum\a}}{\a}      
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Mar 10, 2020 at 10:34
  • The essential parts are copied here.
    – liyistc
    Mar 11, 2020 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .