编辑:

编辑:

它有一个包含 50 个问题的多项选择题文件,想要生成包含不同问题的评估,每个评估的问题数量限制为 10 个,生成 5 个包含不同问题的文件。

 \documentclass[a4paper]{article}

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

    % Packages used for special things
    \usepackage{tikz,framed} 
    \usepackage{fancyhdr,lastpage,totcount,xpatch}
    \usepackage{calc}

    % Set headers and footers
    \pagestyle{fancy}

    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt} 
    \renewcommand{\footrulewidth}{1pt}
    \lfoot{\mctheversion}
    \rfoot{Page \thepage\ of \pageref{LastPage}}

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

    \newtoggle{questionscounted}
    \global\togglefalse{questionscounted}
    \makeatletter
    \newcommand{\patch@mcquestions}{%
      \iftoggle{questionscounted}
        {}
        {%
         \setcounter{numquestions}{\value{mc@counter}}%
         \global\toggletrue{questionscounted}
        }%
    }
    \newcounter{numquestions}
    \regtotcounter{numquestions}
    \xpatchcmd{\env@mcquestions@process}
     {\mc@setQuestionAndAnswerNumbers}
     {\mc@setQuestionAndAnswerNumbers\patch@mcquestions}
     {}{}
    \makeatother


    \begin{document}


    \begin{center}
      \bfseries\LARGE Midterm Exam 
    \end{center}

    \begin{framed}
      \centering\bfseries\Large\MakeUppercase{\mctheversion}
    \end{framed}

    \mcifoutput{concept,exam}{ 

      \bigskip

      \noindent Name: \dotfill\\[.5\baselineskip]
      \noindent Student Number: \dotfill\\[.5\baselineskip]
      \noindent Program: \dotfill  

      \vspace{2\baselineskip}


      \noindent\textbf{Instructions:}
      \begin{itemize}[nosep]
             \item This exam has \total{numquestions} questions. %THIS THROWS AN UNDEFINED CONTROL SEQUENCE ERROR
      \end{itemize}  
    }


    \begin{mcquestions}

    \question What is the color of the sky?

              \begin{mcanswerslist}[fixlast]
              \answer[correct] blue
              \answer green
              \answer red
              \answer yellow
              \answer none of the above
              \end{mcanswerslist}        

              \begin{mcexplanation}
              If you look up to the sky and there are no clouds, you'll see it is blue.
              \end{mcexplanation}

              \begin{mcnotes}
              This question had a large proportion of good answers last year.
              \end{mcnotes}

\question Which figure is a square?
          \begin{mcanswers}
          \begin{tabular}{@{}cccc}
          \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];}}\\
          \answernum{1}&\answernum{2}&\answernum{3}&\answernum{4}\\
          \end{tabular} 
          \end{mcanswers}

\end{mcquestions}

\end{document}

编辑:

我不明白的是编译器无法识别 latex 输入

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[output=exam, numberofversions=58, randomizequestions=true,randomizeanswers=true]{mcexam}
\usepackage{fontspec}%déjà chargé par luatextra
\usepackage[T1]{fontenc} 

\setmainfont[Ligatures=TeX,
Path = ../../Fonts/alegreya/,
UprightFont=Alegreya-regular,
BoldFont=Alegreya-Bold,
ItalicFont=Alegreya-Italic,
BoldItalicFont=Alegreya-BoldItalic,
SmallCapsFont=AlegreyaSC-Regular
]{Alegreya}
%\defaultfontfeatures{Ligatures=TeX} % to have the automatics ligatures of TeX
%\setromanfont{Alegreya}
%\usepackage{geometry,lipsum,xcolor}
\usepackage[a4paper,left=30mm,right=25mm,top=30mm,bottom=25mm,headsep=15.5mm]{geometry}
\geometry{margin=1in}
\usepackage[portuguese]{babel}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{chemfig}
\usepackage{cancel}

\renewenvironment{setmcanswers}{}{}
\setlist[setmcquestions]{label=\mcquestionlabelfmt{*}-
    ,ref=\mcquestionlabelfmt{*}
    ,itemsep=0.5\baselineskip
    ,topsep=1\baselineskip
}

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{1pt}
\lfoot{\mctheversion}
\rfoot{Página \thepage\ de \pageref{LastPage}}

\renewcommand{\CancelColor}{\color{red}}
\usepackage{upgreek}
%\usepackage[method=mhchem]{chemmacros}
\usepackage{chemmacros}
\chemsetup{modules=all}
\usepackage{multicol}
\usepackage{enumitem}

\usepackage{etoolbox}
\patchcmd{\newpage}{\par}{\par\relax}{}{\FAILED}


\foreach \i in {1,...,10}{
\newpage
\setkeys{mcexam.sty}{version=\i,seed=123}


\begin{multicols}{2}
\begin{mcquestions}
\input{../Folder1/file2}
\input{../Folder2/file2}
\end{mcquestions}%%%%%
 \end{multicoLs}
    }
\end{document}

那是文件 1,文件 2 是:

\question What is the color of the sky?

          \begin{mcanswerslist}
          \answer[correct] blue
          \answer green
          \answer red
          \answer yellow
          \answer none of the above
          \end{mcanswerslist}

我不明白的是编译器无法识别 latex 输入

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[output=exam, numberofversions=58, randomizequestions=true,randomizeanswers=true]{mcexam}
\usepackage{fontspec}%déjà chargé par luatextra
\usepackage[T1]{fontenc} 

\setmainfont[Ligatures=TeX,
Path = ../../Fonts/alegreya/,
UprightFont=Alegreya-regular,
BoldFont=Alegreya-Bold,
ItalicFont=Alegreya-Italic,
BoldItalicFont=Alegreya-BoldItalic,
SmallCapsFont=AlegreyaSC-Regular
]{Alegreya}
%\defaultfontfeatures{Ligatures=TeX} % to have the automatics ligatures of TeX
%\setromanfont{Alegreya}
%\usepackage{geometry,lipsum,xcolor}
\usepackage[a4paper,left=30mm,right=25mm,top=30mm,bottom=25mm,headsep=15.5mm]{geometry}
\geometry{margin=1in}
\usepackage[portuguese]{babel}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{chemfig}
\usepackage{cancel}

\renewenvironment{setmcanswers}{}{}
\setlist[setmcquestions]{label=\mcquestionlabelfmt{*}-
    ,ref=\mcquestionlabelfmt{*}
    ,itemsep=0.5\baselineskip
    ,topsep=1\baselineskip
}

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{1pt}
\lfoot{\mctheversion}
\rfoot{Página \thepage\ de \pageref{LastPage}}

\renewcommand{\CancelColor}{\color{red}}
\usepackage{upgreek}
%\usepackage[method=mhchem]{chemmacros}
\usepackage{chemmacros}
\chemsetup{modules=all}
\usepackage{multicol}
\usepackage{enumitem}

\usepackage{etoolbox}
\patchcmd{\newpage}{\par}{\par\relax}{}{\FAILED}


\foreach \i in {1,...,10}{
\newpage
\setkeys{mcexam.sty}{version=\i,seed=123}


\begin{multicols}{2}
\begin{mcquestions}
\input{../Folder1/file2}
\input{../Folder2/file2}
\end{mcquestions}%%%%%
 \end{multicoLs}
    }
\end{document}

那是文件 1,文件 2 是:

\question What is the color of the sky?

          \begin{mcanswerslist}
          \answer[correct] blue
          \answer green
          \answer red
          \answer yellow
          \answer none of the above
          \end{mcanswerslist}

相关内容