0

I'm trying to make the choices of my questions to look like this:

1. Question ....
   (A) choice ....                                 (B) choice ....
   (C) choice ....                                 (D) choice ....
   (E) choice ....

But, if I use this answer, the space between the question and choice (A) would be different from the default \question and \choice in the questions environment. There is a similar question, but the documentclass is different. Also, I would like to order the choices in (A)(B)(C)(D)(E) (as shown above), not (A)(D)(B)(E)(C) (Example Question 1 below).

Here is my MWE

\documentclass[11pt, a4paper, addpoints]{exam}
\usepackage[top=1.2in, bottom=1.2in, left=1.23in, right=1.23in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[utf8x]{inputenc}
\usepackage{enumitem}
\usepackage{ragged2e}
\usepackage{multicol}

\renewcommand{\questionshook}{% \setlength{\leftmargin}{20pt}% }

\renewcommand{\choiceshook}{% \setlength{\leftmargin}{18pt}% }

\renewcommand{\checkboxeshook}{% \setlength{\leftmargin}{18pt}% }

\renewcommand\choicelabel{(\Alph{choice})} \renewcommand{\thepartno}{\arabic{partno}}

\newlist{choicesnew}{enumerate}{1} \setlist[choicesnew]{label=(\Alph), topsep=0pt} \newcommand{\choicenew}{\item}

\setlength\columnsep{40pt}

\SetEnumitemKey{twocol}{ before=\raggedcolumns\begin{multicols}{2}, after=\end{multicols}}

\SetEnumitemKey{threecol}{ before=\raggedcolumns\begin{multicols}{3}, after=\end{multicols}}

\begin{document} \justifying \pointsinrightmargin

\pointpoints{%}{%}

\begin{questions} \question Example Question 1

\begin{choicesnew}[twocol] \choicenew Answer 1 \choicenew Answer 2 \choicenew Answer 3 \choicenew Answer 4 \choicenew Answer 5 \end{choicesnew}

\question Example Question 2

\begin{choices} \choice Answer 1 \choice Answer 2 \choice Answer 3 \choice Answer 4 \choice Answer 5 \end{choices}

\end{questions} \end{document}

enter image description here

E. Huang
  • 201
  • The order (top to bttom, then left to right) is inevitable with multicol and lists. Since \item adds a \par, You would be better off using a tabular or \makebox approach. – John Kormylo Oct 31 '22 at 13:38

1 Answers1

1

This shows a \makebox version. It uses a minipage instead of a list. Consequently, it will not break over pages. Nor does it handle correct choice or print answers options (too much work).

\documentclass[11pt, a4paper, addpoints]{exam}
\usepackage[top=1.2in, bottom=1.2in, left=1.23in, right=1.23in, showframe]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[utf8x]{inputenc}
\usepackage{ragged2e}

% udbox is a \vbox version of lrbox \makeatletter \def\udbox#1{% \edef\reserved@a{% \endgroup \setbox#1\vbox{% \begingroup\aftergroup}% \def\noexpand@currenvir{@currenvir}% \def\noexpand@currenvline{\on@line}}% \reserved@a @endpefalse \color@setgroup \ignorespaces} \def\endudbox{\unskip\color@endgroup}

\newenvironment{shortchoices}[1][2]{% #1 = number of columns \count1=#1\relax \settowidth{\labelwidth}{W.\hskip\labelsep}% \setlength{\leftmargin}{\dimexpr\labelsep+2.5em}% \setlength{\dimen0}{\dimexpr \linewidth-\leftmargin}% column width \ifnum\count1>0 \divide\dimen0 by \count1 \fi \advance\dimen0 by -\labelsep \begin{udbox}{0}% fill single solomn @totalleftmargin=-2.5em \linewidth=\dimexpr \dimen0+2.5em\relax \choices}% {\endchoices \end{udbox}% now shuffle contents \count2=0 \loop\ifvoid0 \else \ifnum\count2=0 \par\noindent\hskip 2.5em \fi \setbox1=\vsplit0 to \baselineskip \setbox2=\vbox{\unvbox1}% restore height \usebox2\hskip\labelsep \advance\count2 by 1 \ifnum\count2=\count1 \count2=0 \fi \repeat \par\medskip } \makeatother

\begin{document} \justifying \pointsinrightmargin

\pointpoints{%}{%}

\begin{questions} \question Example Question 1

\begin{shortchoices}[3] \choice Answer 1 \choice Answer 2 \choice Answer 3 \choice Answer 4 \choice Answer 5 \choice Answer 6 \choice Answer 7 \end{shortchoices}

\question Example Question 2

\begin{choices} \choice Answer 1 \choice Answer 2 \choice Answer 3 \choice Answer 4 \choice Answer 5 \end{choices}

\end{questions} \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120