mcexam 自定义类型问题

mcexam 自定义类型问题

我正在尝试使用提供的代码创建考试

以下是代码:

\documentclass[twoside]{article}
\usepackage[english]{babel}

% set fonts
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage{microtype}
\usepackage{etoolbox}

\ifdef{\myoutput}{}{\def\myoutput{concept}}
\ifdef{\myversion}{}{\def\myversion{1}}

% mcexams options.
\usepackage[output=exam%\myoutput
           ,numberofversions=2
           ,version=\myversion
           ,seed=1
           ,randomizequestions=true
           ,randomizeanswers=true
           ,writeRfile=true
           ]{mcexam}

\usepackage[margin=0.95in]{geometry}

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

% Set headers and footers
\usepackage{fancyhdr,lastpage}
\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.
\usepackage{calc}
\renewenvironment{setmcquestion}{\begin{minipage}[t]{\linewidth-\labelwidth}}{\end{minipage}\par}

% question intros should also be printed on the same page.
\renewenvironment{setmcquestioninstruction}
{\begin{minipage}{\textwidth}}
{\end{minipage}}

\usepackage{multicol}

% disable paragraph indenting
\setlength{\parindent}{0cm} % Default is 15pt.

% no extra space between sentences
\frenchspacing

% fix test spacing wonkiness due to grouped questions
\raggedbottom

% less space for true/false questions
\renewenvironment{setmcanswers}{}{}
\setlist[setmcquestions]{label=\mcquestionlabelfmt{*}.
                        ,ref=\mcquestionlabelfmt{*}
                        ,itemsep=0.5\baselineskip   
                        ,topsep=1\baselineskip
                        }

% use Version 1, 2 etc instead of I, II
\renewcommand\mcversionlabelfmt[1]{\arabic{#1}}

\usepackage{array}

\usepackage{xparse}
% Rotation macro
% Rotation: \rot[<angle>][<width>]{<stuff>}
\NewDocumentCommand{\rot}{O{45} O{1em} m}{\makebox[#2][l]{\rotatebox{#1}{#3}}}%


% macro for true/false correct answers
\global\def\qtrue{\begin{mcanswers}[permutenone]\answer[correct]{1}{}\answer{2}{}\end{mcanswers}}
\global\def\qfalse{\begin{mcanswers}[permutenone]\answer{1}{}\answer[correct]{2}{}\end{mcanswers}}

% macro for question intros that list the number of questions
\global\def\numq[#1]{[Questions \the\numexpr\value{setmcquestionsi}+1\relax--\the\numexpr\value{setmcquestionsi}+#1\relax]}

\usepackage{graphicx}

% ensure always one blank page at end
\mcifoutput{exam}{
\AtEndDocument{\ifodd\value{page}
\newpage\thispagestyle{empty}\hbox{\hfill{}This page intentionally left blank.\hfill{}}\newpage\thispagestyle{empty}\hbox{}
\else
\newpage\thispagestyle{empty}\hbox{}
\fi}
}

% custom hyphenation
\hyphenation{al-kap-to-nu-ri-a}


\begin{document}


% Exam preamble stuff - this will be printed on every version
\begin{center}
  \bfseries\Huge My Favorite Exam \\
  \LARGE 
  \today
\end{center}

% Show which version is being printed (Concept, Answers, etc.)
\begin{center}\bfseries\Huge\MakeUppercase{\mctheversion}\end{center}

% This only shows on the "Exam" form that students see. So put instructions, etc. here.
\mcifoutput{exam}{
\large\bigskip

\noindent Name: \hrulefill{}\hrulefill{}\hrulefill{}\quad{}Student ID\#: \hrulefill\hrulefill{} \\[.75\baselineskip]

\vfill

\begin{framed} \centering\bfseries\Large No calculators allowed!  \end{framed}

\vfill

On your scantron, use a \#2 pencil to:

\begin{enumerate}
\item \textbf{Write and bubble your last name, first name, and student ID\#}
\item \textbf{Write and bubble your exam version}
\end{enumerate}

% ensure that questions don't get printed on this intro page, which annoys students
\cleardoublepage
\renewcommand{\baselinestretch}{1.05}
\normalsize
} % end if exam


%%%%%%%%%%%%%%%%%%%%%%%%
% BEGIN EXAM QUESTIONS %
%%%%%%%%%%%%%%%%%%%%%%%%

\begin{mcquestions}

\question Which of the following numbers is prime? This shows how \texttt{multicol} can be used to format options all on one line.

\begin{multicols}{4}
\begin{mcanswerslist}[ordinal]
    \answer 12
    \answer 16
    \answer[correct] 17
    \answer 20
\end{mcanswerslist}
\end{multicols}

\begin{mcquestioninstruction}
\numq[5] Which of the following foods can be eaten on a keto diet? Mark A for True and B for False. This shows how we can use the True/False macros and custom edits to \texttt{mcexam.sty} to produce a compact series of True/False questions. 
\end{mcquestioninstruction}

\question         Blueberries \qtrue
\question[follow] Eggs        \qtrue
\question[follow] Steak       \qtrue
\question[follow] Bread       \qfalse
\question[follow] Cupcakes    \qfalse


\question Which combination of of hexadecimal values is orange? This is an example of some fancy stuff in \texttt{mcexam}. The options below are formatted like a table (using extensive amounts of spacing) and will also be randomized on different exam versions.

\begin{mcanswers}

\bigskip
\begin{minipage}{0.5\textwidth}
\hspace{2.2em}\makebox[4em]{\textbf{Red}}\hfill\makebox[5em]{\textbf{Green}}\hfill\makebox[5em]{\textbf{Blue}}\par

\makebox[1em]{\answernum{1}}\quad\answer[correct]{1}{\makebox[5em]{ff}\hfill\makebox[5em]{aa}\hfill\makebox[5em]{00}}\par

\makebox[1em]{\answernum{2}}\quad\answer{2}{\makebox[5em]{cc}\hfill\makebox[5em]{00}\hfill\makebox[5em]{44}}\par

\makebox[1em]{\answernum{3}}\quad\answer{3}{\makebox[5em]{ff}\hfill\makebox[5em]{ff}\hfill\makebox[5em]{ff}}\par

\makebox[1em]{\answernum{4}}\quad\answer{4}{\makebox[5em]{00}\hfill\makebox[5em]{00}\hfill\makebox[5em]{00}}\par

\makebox[1em]{\answernum{5}}\quad\answer{5}{\makebox[5em]{33}\hfill\makebox[5em]{66}\hfill\makebox[5em]{99}}
\end{minipage}

\end{mcanswers}


\begin{mcquestioninstruction}
\numq[6] Read A opposite. Complete this text with words from exerciseI. Use the context to help you.\\
Computers have changed the way we do everyday things, such as
working, shopping and looking for information. We (1)-----------
houses with the help of PCs; we buy books or make flight reservations
on the (2)----------- ; we use gadgets that spring to life the
instant they are switched on, for example the mobile phone, the music
player, or the car ignition, all of which use (3)----------- Many
people now work at home, and they communicate with their office by
computer and telephone. This is called 'teleworking'. With the appropriate hardware and software, a PC can do almost
anything you ask. It's a magical typewriter that allows you to type and (4)--------------any sort of document. It's a calculating machine that makes (5)-------------calculations. It's a filing cabinet that
manages large collections of data. It's a personal communicator that lets
you interact with friends, it's a small lab that helps you edit photos and
movies. And if you like (6)------------ entertainment, you can also
use it to relax with games.
\end{mcquestioninstruction}
\question This is number 6 which relates to number (1) in the text. 
\question[follow] I want number (2) in the next be set with this question number which is 7
\question[follow] 
\question[follow]
\question [follow]
\question [follow] 

\end{mcquestions}


\end{document}

我的问题如下图所示。在问题 6 到 11 中,被定义为问题组的问题集设置了一个问题编号计数器。我也想在文本中复制该编号。也就是说,我想在文本中打印 (6) 而不是 (1)(因为问题顺序是随机的,我不能简单地写 (6),因为这可能会使问题组从 6-11 变为 11-16!)。还应该重置它以应对下一组问题。

在此处输入图片描述 如果有人能给我一些解决方案,我将非常感激。谢谢

答案1

我定义了一个新的宏来解决我的问题:

\global\def\numqq[#1]{(\the\numexpr\value{setmcquestionsi}+#1\relax)}

相关内容