Incomplete \ifx if randomizing on one machine, but not on the other (mcexam)

folks---

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:

\documentclass[a4paper]{article}

\usepackage[output=concept
,numberofversions=4
,version=1
,seed=1
,randomizequestions=true
,writeRfile=true
]{mcexam}

% Packages used for special things
\usepackage{tikz,framed}

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{1pt}
\lfoot{\mctheversion}
\rfoot{Page \thepage\ of \pageref{LastPage}}

% Ensure each question+answers is printed entirely on the same page.
\usepackage{calc}
\renewenvironment{setmcquestion}{\begin{minipage}[t]{\linewidth-\labelwidth}}{\end{minipage}\par}

\begin{document}

\begin{mcquestions}

\question What is the color of the sky?

\question Which figure is a square?
\begin{tabular}{@{}cccc}
\end{tabular}

\end{mcquestions}

\end{document}


• Welcome to TeX.SX! You should never enable symbolic links when installing on Debian with install-tl. – egreg Oct 3 '19 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 '19 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 '19 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 '19 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 '19 at 13:45

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 \v in {1,...,\mc@totalNumberOfVersions}{
\foreach \x in {1,...,\@numberofswaps}{