1

I am trying to write a multiple choice exam with the exam package. For each questions I have 6 possible answers (3 in each line). Here is a minimal work example.

\documentclass[addpoints]{exam}
\begin{document}

\begin{center}
\gradetable
\end{center}


\begin{questions}

\titledquestion{\textbf{Multiple Choice}}[10]


What is the capital of the United states?

\begin{oneparchoices}
\choice NY 
\choice Texas
\choice LA \\\\
\choice San Antonio
\choice Chicago
\CorrectChoice Washington D.C.



\end{oneparchoices}

\end{questions}

\end{document}

I want to have every three answer distributed evenly in one line with equal spaces between them and to have answer a above d and b above e and c above f directly.

Thanks

0

I rely on egreg's code (as most of the times) which he gave me on one of the occasions when I was a victim of similar requirement. Here is a slight modification of his code and I have defined a new environment myoneparchoices so that you will have the original oneparchoices intact.

\documentclass[addpoints]{exam}

\usepackage{environ,xparse}

%% ------------------egreg's code begins---------------------------
\ExplSyntaxOn
\cs_undefine:N \choices
\cs_undefine:N \endchoices
\NewEnviron{myoneparchoices}{%
  \par\nopagebreak
  \abd_dochoices:V \BODY
  \par
}
\tl_new:N \l_abd_choices_tl
\seq_new:N \l_abd_choices_seq
\seq_new:N \l_abd_choices_final_seq

\cs_new_protected:Npn \abd_dochoices:n #1
 {
  \setcounter{choice}{0}
  \tl_set:Nn \l_abd_choices_tl { #1 }
  \tl_replace_once:Nnn \l_abd_choices_tl { \CorrectChoice } { \choice* }
  \seq_set_split:NnV \l_abd_choices_seq { \choice } \l_abd_choices_tl
  \seq_pop_left:NN \l_abd_choices_seq \l_tmpa_tl
  \seq_set_map:NNn \l_abd_choices_final_seq \l_abd_choices_seq
   { \exp_not:n { \makechoice ##1 } }
    \seq_map_inline:Nn \l_abd_choices_final_seq
   {
    \makebox[.3333333333333333333\linewidth][l]{
      \parbox[t]{.3\linewidth}{\raggedright \hangindent1.5em ##1\strut}
    }\hspace{0pt plus .1\linewidth}
   }
 }
\cs_generate_variant:Nn \abd_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

\begin{document}

\begin{center}
\gradetable
\end{center}


\begin{questions}

\titledquestion{\textbf{Multiple Choice}}[10]


What is the capital of the United states?

\begin{myoneparchoices}
\choice NY
\choice Texas
\choice LA
\choice San Antonio
\choice Chicago
\CorrectChoice Washington D.C.
\end{myoneparchoices}

\end{questions}

\end{document}

enter image description here

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.