到目前为止,我还没有找到这个问题,所以我将它发布出来:
我使用 mcexam 软件包编写了一个测验。在我的 Mac 上,它可以完美编译,但出于某种原因,在我所有的 Windows 机器上(我尝试使用 TeXLive 2019 和 MikTeX 以确保无误),如果我使用选项 randomizeanswers=true,则在编译过程中会出现以下错误:
“不完整的 \ifx;第 74 行之后的所有文本都被忽略。”
作为参考,第 74 行是文档的末尾,紧接着“\end{mcquestions}”
同样,相同的文件在 MacTex 上编译时没有任何问题,但在 Windows TeXLive 上却不行,这让我很困惑。
梅威瑟:
\documentclass{article}
\usepackage[left=0.5in,right=0.5in,top=1in,bottom=1in,headsep=3ex]{geometry}
\usepackage[output=concept,numberofversions=5,version=1,seed=09092019,randomizeanswers=false,randomizequestions=false]{mcexam}
\usepackage{physics}
\usepackage{graphicx}
\usepackage{calc}
\usepackage[per-mode=symbol,inter-unit-product=\cdot]{siunitx}
\title{Test, \mctheversion}
\author{Test}
\date{9/9/2019}
\renewcommand\mcversionlabelfmt[1]{\arabic{#1}}
\renewenvironment{setmcquestion}{\begin{minipage}[t]{\linewidth-\labelwidth}}{\end{minipage}\par}
\begin{document}
\maketitle
\begin{mcquestions}
\question What is the answer to question 1 on the homework?
\begin{mcanswerslist}
\answer[correct] \SI{39.8}{\km} N, \SI{35.0}{\km} W
\answer \SI{35.0}{\m} N, \SI{39.8}{\m} W
\answer \SI{39.8}{\m} N, \SI{35.0}{\m} W
\answer \SI{35.0}{\km} N, \SI{39.8}{\km} W
\end{mcanswerslist}
\end{mcquestions}
\end{document}
在上面的例子中,如果按照我的理解“randomizeanswers=false”,这段代码就可以编译,如果我将其切换为“randomizeanswers=true”,那么它会在我的 Windows 机器上失败,但在我的 Mac 上仍然可以正常运行。
从 Windows 计算机:
article.cls 2018/09/03 v1.4i Standard LaTeX document class
size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
geometry.sty 2018/04/16 v5.8 Page Geometry
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
ifpdf.sty 2018/09/07 v3.3 Provides the ifpdf switch
ifvtex.sty 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
mcexam.sty 2017/12/26 v0.4 LaTeX package for creating randomized Multiple
Choice questions
xkeyval.sty 2014/12/03 v2.7a package option processing (HA)
xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
etoolbox.sty 2018/08/19 v2.5f e-TeX tools for LaTeX (JAW)
environ.sty 2014/05/04 v0.3 A new way to define environments
trimspaces.sty 2009/09/17 v1.1 Trim spaces around a token list
newfile.sty 2009/09/03 v1.0c Output and input files
verbatim.sty 2014/10/28 v1.5q LaTeX2e package for verbatim enhancements
enumitem.sty 2019/06/20 v3.9 Customized lists
longtable.sty 2014/10/28 v4.11 Multi-page Table package (DPC)+ FMi change
pgffor.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfrcs.sty 2019/08/03 v3.1.4b (3.1.4b)
everyshi.sty 2001/05/15 v3.00 EveryShipout Package (MS)
pgfrcs.code.tex
pgfkeys.sty
pgfkeys.code.tex
pgfmath.sty
pgfmath.code.tex
pgffor.code.tex
xstring.sty 2019/02/06 v1.83 String manipulations (CT)
physics.sty
xparse.sty 2019-05-28 L3 Experimental document command parser
expl3.sty 2019-09-05 L3 programming layer (loader)
expl3-code.tex 2019-09-05 L3 programming layer
l3backend-pdfmode.def 2019-04-06 v L3 backend support: PDF mode
amsmath.sty 2018/12/01 v2.17b AMS math features
amstext.sty 2000/06/29 v2.01 AMS text
amsgen.sty 1999/11/30 v2.0 generic functions
amsbsy.sty 1999/11/29 v1.2d Bold Symbols
amsopn.sty 2016/03/08 v2.02 operator names
graphicx.sty 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
calc.sty 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
siunitx.sty 2018/05/17 v2.7s A comprehensive (SI) units package
array.sty 2018/12/30 v2.4k Tabular extension package (FMi)
l3keys2e.sty 2019-05-28 LaTeX2e option processing using LaTeX3 keys
translator.sty 2019-05-31 v1.12a Easy translation of strings in LaTeX
supp-pdf.mkii
epstopdf-base.sty 2016/05/15 v2.6 Base part for package epstopdf
infwarerr.sty 2016/05/16 v1.4 Providing info/warning/error messages (HO)
grfext.sty 2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty 2016/05/16 v1.4 Define keys (HO)
ltxcmds.sty 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
kvoptions.sty 2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty 2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty 2016/05/16 v1.4 Provides the ifluatex switch (HO)
pdftexcmds.sty 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
ts1enc.dfu 2018/10/05 v1.2f UTF-8 support for inputenc
translator-basic-dictionary-English.dict
siunitx-abbreviations.cfg 2017/11/26 v2.7k siunitx: Abbreviated units
***********
从 mac
*File List*
article.cls 2018/09/03 v1.4i Standard LaTeX document class
size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
geometry.sty 2018/04/16 v5.8 Page Geometry
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
ifpdf.sty 2018/09/07 v3.3 Provides the ifpdf switch
ifvtex.sty 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
mcexam.sty 2017/12/26 v0.4 LaTeX package for creating randomized Multiple
Choice questions
xkeyval.sty 2014/12/03 v2.7a package option processing (HA)
xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
etoolbox.sty 2018/08/19 v2.5f e-TeX tools for LaTeX (JAW)
environ.sty 2014/05/04 v0.3 A new way to define environments
trimspaces.sty 2009/09/17 v1.1 Trim spaces around a token list
newfile.sty 2009/09/03 v1.0c Output and input files
verbatim.sty 2014/10/28 v1.5q LaTeX2e package for verbatim enhancements
enumitem.sty 2019/06/20 v3.9 Customized lists
longtable.sty 2014/10/28 v4.11 Multi-page Table package (DPC)+ FMi change
pgffor.sty 2019/05/09 v3.1.3 (3.1.3)
pgfrcs.sty 2019/05/09 v3.1.3 (3.1.3)
everyshi.sty 2001/05/15 v3.00 EveryShipout Package (MS)
pgfrcs.code.tex
pgfkeys.sty
pgfkeys.code.tex
pgfmath.sty
pgfmath.code.tex
pgffor.code.tex
xstring.sty 2019/02/06 v1.83 String manipulations (CT)
physics.sty
xparse.sty 2019-05-28 L3 Experimental document command parser
expl3.sty 2019-05-28 L3 programming layer (loader)
expl3-code.tex 2019-05-28 L3 programming layer
l3pdfmode.def 2019-04-06 v L3 Experimental driver: PDF mode
amsmath.sty 2018/12/01 v2.17b AMS math features
amstext.sty 2000/06/29 v2.01 AMS text
amsgen.sty 1999/11/30 v2.0 generic functions
amsbsy.sty 1999/11/29 v1.2d Bold Symbols
amsopn.sty 2016/03/08 v2.02 operator names
graphicx.sty 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
calc.sty 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
siunitx.sty 2018/05/17 v2.7s A comprehensive (SI) units package
array.sty 2018/12/30 v2.4k Tabular extension package (FMi)
l3keys2e.sty 2019-05-28 LaTeX2e option processing using LaTeX3 keys
translator.sty 2019-05-31 v1.12a Easy translation of strings in LaTeX
supp-pdf.mkii
epstopdf-base.sty 2016/05/15 v2.6 Base part for package epstopdf
infwarerr.sty 2016/05/16 v1.4 Providing info/warning/error messages (HO)
grfext.sty 2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty 2016/05/16 v1.4 Define keys (HO)
ltxcmds.sty 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
kvoptions.sty 2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty 2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty 2016/05/16 v1.4 Provides the ifluatex switch (HO)
pdftexcmds.sty 2018/09/10 v0.29 Utility functions of pdfTeX for LuaTeX (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
ts1enc.dfu 2018/10/05 v1.2f UTF-8 support for inputenc
translator-basic-dictionary-English.dict
siunitx-abbreviations.cfg 2017/11/26 v2.7k siunitx: Abbreviated units
***********
答案1
mc@randomizeAnswers@permuteall
我昨天也遇到了这个错误,我自己已经通过对中的函数进行以下几行更改(第 1060 行添加一项,第 1063 行更新一项)来修复它mcexam.sty
。希望这对您有所帮助。
--- /usr/local/texlive/2019/texmf-dist/tex/latex/mcexam/mcexam.sty
+++ mcexam.sty
@@ -1055,23 +1055,24 @@
\def\mc@randomizeAnswers@permuteall{
\foreach \a in {1,...,\csuse{mc@totalNumberOfAnswersQ\q}}{
\csxdef{mc@answerTempnum\a}{\a}
}
+ \numdef\@numberofpermuteanswers{\csuse{mc@totalNumberOfAnswersQ\q}}
\numdef\@numberofswaps{\csuse{mc@totalNumberOfAnswersQ\q}-1}
\foreach \v in {1,...,\mc@totalNumberOfVersions}{
\foreach \x in {1,...,\@numberofswaps}{
- \pgfmathrandominteger{\r}{\x}{\csuse{mc@totalNumberOfAnswersQ\q}}
+ \pgfmathrandominteger{\r}{\x}{\@numberofpermuteanswers}
\letcs\@temp{mc@answerTempnum\x}
\global\csletcs{mc@answerTempnum\x}{mc@answerTempnum\r}
\global\cslet{mc@answerTempnum\r}{\@temp}
}
\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}
}
}
}