EXAM 类别 : 相邻选择

EXAM 类别 : 相邻选择

目前,使用多列和考试类别,我能够以以下格式生成 MCQ 试卷:

Q.1 : Quiescent centre is found in plants at :
A. Shoot tip              C. Root tip
B. Cambium                D. Leaf tip

是否有任何选项可以将选项排列为

Q.1 : Quiescent centre is found in plants at :
A. Shoot tip              B. Cambium
C. Root tip               D. Leaf tip

答案1

最近,Enrico (egreg) 为我提供了一个用于相同目的的代码。我希望他不介意我分享它。功劳应该归于他。

\documentclass[
  answers,12pt
]{exam}
\usepackage{environ,xparse}

\usepackage[per-mode = symbol,detect-weight]{siunitx} 
\DeclareSIUnit\Nm{Nm}

%% ------------------egreg's code begins---------------------------
\ExplSyntaxOn
\cs_undefine:N \choices
\cs_undefine:N \endchoices
\NewEnviron{choices}{%
  \par\nopagebreak
  \harish_dochoices:V \BODY
  \par
}
\tl_new:N \l_harish_choices_tl
\seq_new:N \l_harish_choices_seq
\seq_new:N \l_harish_choices_final_seq

\cs_new_protected:Npn \harish_dochoices:n #1
 {
  \setcounter{choice}{0}
  \tl_set:Nn \l_harish_choices_tl { #1 }
  \tl_replace_once:Nnn \l_harish_choices_tl { \CorrectChoice } { \choice* }
  \seq_set_split:NnV \l_harish_choices_seq { \choice } \l_harish_choices_tl
  \seq_pop_left:NN \l_harish_choices_seq \l_tmpa_tl
  \seq_set_map:NNn \l_harish_choices_final_seq \l_harish_choices_seq
   { \exp_not:n { \makechoice ##1 } }
  \seq_map_inline:Nn \l_harish_choices_final_seq
   {
    \makebox[.5\linewidth][l]{
      \parbox[t]{.45\linewidth}{\raggedright \hangindent1.5em ##1\strut}
    }\hspace{0pt plus .3\linewidth}
   }
 }
\cs_generate_variant:Nn \harish_dochoices:n { V }
\ExplSyntaxOff
\makeatletter
\NewDocumentCommand{\makechoice}{s}
 {
  \stepcounter{choice}
  \IfBooleanT{#1}{\ifprintanswers\CorrectChoice@Emphasis\fi}
  {\normalfont\makebox[1.2em][l]{\IfBooleanT{#1}{\ifprintanswers\CorrectChoice@Emphasis\fi}\Alph{choice})}}
 }
\makeatother
\CorrectChoiceEmphasis{\bfseries\boldmath}
%% --- egreg's code ends-----------------------------
%%---------------------------------------------------------
\begin{document}

\begin{questions}
\question
When a force of \SI{1}{\newton} acts on a \SI{1}{\kilo\gram} body that is able to move freely, the body receives
\begin{choices}
\choice a speed of \SI{1}{\meter\per\second}
\CorrectChoice an acceleration of \SI{1}{\meter\per\second\squared}
\choice an acceleration of \SI{980}{\meter\per\second\squared}
\choice none of these
\end{choices}

\question
The equation $ v^2 = u^2 + 2as$, where the symbols have their usual meanings, follows from
\begin{choices}
\choice Newton's first law
\choice Newton's second law (some text just to push the line to second)
\choice Newton's third law
\CorrectChoice none of these
\end{choices}
%
\end{questions}
%
\end{document}

在此处输入图片描述

相关内容