3

Currently using multicol and exam class I'm able to generate MCQ question paper in the formats mentioned below:

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

Is there any option to arrange options as

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

Recently Enrico (egreg) provided me a code for the same purpose. I hope he won't mind if I share it. Credits should go to him.

\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}

enter image description here

1
  • 2
    @egreg: Hope you don't mind :-)
    – user11232
    Nov 15 '13 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.