5

I'm a fairly new LaTeX user, so please excuse me if this is a simple newbie question.

I am using the exam package to create, well, an exam. I use both the \choices and \oneparchoices environments and I would like them to be aligned instead of the choices ones being far more indented. This MWE should illustrate my point:

\documentclass{exam}

\begin{document}

\begin{questions}

   \question
    Question 1

   \begin{oneparchoices}
       \correctchoice Answer 1
       \choice Answer 2
       \choice Answer 3
   \end{oneparchoices}

   \question
   Question 2

   \begin{choices}
    \correctchoice Answer 1
    \choice Answer 2
    \choice Answer 3
   \end{choices}

   \end{questions}

 \end{document}

This is what I get.

I'm sure the more experienced users can solve this easily, but I'm stuck.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127

1 Answers1

3

Having a look at the source code of the exam class shows me that the left margin (realized as \leftmargin in LaTeX) is set by choices using a hard coded line \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%, i.e. it is set to the width of W. + labelsep + 2.5em (em is relative to your font size).

I don't see an easy way to change that as there is no setting for this provided. You only could copy the definition of choices from exam.cls into your document, between \makeatletter and \makeatother, and change the above line to \setlength{\leftmargin}{<your prefered length>}. I would recommend here 15pt which is the normal \parindent. Your can't apparently not use \parindent directly as the list environment in choices seems to redefine it.
You also need to change \newcommand to \renewcommand of course.

\documentclass{exam}

\makeatletter
% from exam.cls, line 4107:
\renewenvironment{choices}%
  {\list{\choicelabel}%
     {\usecounter{choice}\def\makelabel##1{\hss\llap{##1}}%
       \setlength{\leftmargin}{15pt}%
       \def\choice{%
         \if@correctchoice
           \color@endgroup
           \endgroup
         \fi
         \item
         \do@choice@pageinfo
       } % choice
       \def\CorrectChoice{%
         \if@correctchoice
           \color@endgroup
           \endgroup
         \fi
         \ifprintanswers
           \ifhmode \unskip\unskip\unvbox\voidb@x \fi
           \begingroup \color@begingroup \@correctchoicetrue
           \CorrectChoice@Emphasis
         \fi
         \item
         \do@choice@pageinfo
       } % CorrectChoice
       \let\correctchoice\CorrectChoice
       \labelwidth\leftmargin\advance\labelwidth-\labelsep
       \topsep=0pt
       \partopsep=0pt
       \choiceshook
     }%
  }%
  {\if@correctchoice \color@endgroup \endgroup \fi \endlist}
\makeatother

\begin{document}

\begin{questions}

   \question
    Question 1

   \begin{oneparchoices}
       \correctchoice Answer 1
       \choice Answer 2
       \choice Answer 3
   \end{oneparchoices}

   \question
   Question 2

   \begin{choices}
    \correctchoice Answer 1
    \choice Answer 2
    \choice Answer 3
   \end{choices}

   \end{questions}

 \end{document}

enter image description here

Martin Scharrer
  • 262,582