3

I am making a multiple choice calculus test and have the following code.

\documentclass[12pt]{article}

\usepackage{amsmath,amssymb}
\usepackage[margin=1in]{geometry}
\usepackage{enumerate}
\usepackage{multicol}

\begin{document}

\begin{enumerate}[1) ]

% QUESTION 6
\item Solve for \(x\): \(x=\cfrac{1}{2-\cfrac{1}{2+\cfrac{1}{2-\cfrac{1}{2+\ddots}}}}\)
\begin{multicols}{5}
\begin{enumerate}[(A) ]
\item \(\sqrt{2}\)
\item \(\dfrac{\sqrt{5}-1}{2}\) %CORRECT
\item \(\dfrac{1+\sqrt{5}}{2}\)
\item \(\dfrac{1}{\sqrt{3}}\)
\item NOTA
\end{enumerate}
\end{multicols}

\end{enumerate}

\end{document}

However, this produces the following. Note how choice A is vertically above the other choices.

enter image description here

How do I fix this? Note that I also have the answer choices horizontally aligned with other questions' corresponding choices, like this.

enter image description here

Arcturus
  • 558

4 Answers4

5

The tasks package can do that most simply:

\documentclass[12pt]{article}

\usepackage{amsmath,amssymb}
\usepackage[margin=1in, showframe]{geometry}
\usepackage{enumerate, tasks}
\settasks{counter-format =(tsk[A]),label-offset =1em}

\begin{document}

\begin{enumerate}[1)]

% QUESTION 6
\item Solve for \(x\): \(x=\cfrac{1}{2-\cfrac{1}{2+\cfrac{1}{2-\cfrac{1}{2+\ddots}}}}\)
\begin{tasks}(5)
\task \(\sqrt{2}\)
\task \(\dfrac{\sqrt{5}-1}{2}\) %CORRECT
\task \(\dfrac{1+\sqrt{5}}{2}\)
\task \(\dfrac{1}{\sqrt{3}}\)
\task NOTA
\task \(1 + \sqrt{3}\)
\end{tasks}

\end{enumerate}

\end{document} 

enter image description here

Bernard
  • 271,350
0

This is the multicol environment - in the documentation of the multicol package it says it tries to align baseline, but with only one line per column it obviously has a hard time doing this.

As a workaround, add something invisible so that all the lines have the same height and depth, or at least increase the height of the first line of each column in the multicol environment.

For example

\documentclass[12pt]{article}

\usepackage{amsmath,amssymb}
\usepackage[margin=1in]{geometry}
\usepackage{enumerate}
\usepackage{multicol}

\begin{document}

\begin{enumerate}[1) ]

% QUESTION 6
\item Solve for \(x\): \(x=\cfrac{1}{2-\cfrac{1}{2+\cfrac{1}{2-\cfrac{1}{2+\ddots}}}}\)
\begin{multicols}{5}
\begin{enumerate}[(A) ]
\item \(\sqrt{2}\)\vphantom{\(\dfrac{\sqrt{5}-1}{2}\)}
\item \(\dfrac{\sqrt{5}-1}{2}\) %CORRECT
\item \(\dfrac{1+\sqrt{5}}{2}\)\vphantom{\(\dfrac{\sqrt{5}-1}{2}\)}
\item \(\dfrac{1}{\sqrt{3}}\)\vphantom{\(\dfrac{\sqrt{5}-1}{2}\)}
\item NOTA\vphantom{\(\dfrac{\sqrt{5}-1}{2}\)}
\end{enumerate}
\end{multicols}

\end{enumerate}

\end{document}

enter image description here

0

You could try the enumitem package with the inline option for horizontal lists in lieu of multicol:

\documentclass[12pt]{article}

\usepackage{amsmath,amssymb}
\usepackage[margin=1in]{geometry}
\usepackage[inline]{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]

% QUESTION 6
\item Solve for \(x\): \(x=\cfrac{1}{2-\cfrac{1}{2+\cfrac{1}{2-\cfrac{1}{2+\ddots}}}}\)

\noindent\begin{enumerate*}[label=(\Alph*),itemjoin = \hspace{0.5in}]
\item \(\sqrt{2}\)
\item \(\dfrac{\sqrt{5}-1}{2}\) %CORRECT
\item \(\dfrac{1+\sqrt{5}}{2}\)
\item \(\dfrac{1}{\sqrt{3}}\)
\item NOTA
\end{enumerate*}
\end{enumerate}

\end{document}

result

Guho
  • 6,115
  • My apologies for not specifying further, but I want to be aligning the choices (B), (C), (D), and (E) horizontally on the page as well. Is there a way to do this with enumitem? – Arcturus Dec 15 '15 at 01:29
  • @Guho: I'm terribly sorry: I wanted to update my my answer, and didn't notice I was updating yours. I could set the text back to its previous state, but the image is lost. – Bernard Dec 15 '15 at 02:20
  • @Bernard: No worries, image replaced. tasks is an excellent suggestion by the way; +1. – Guho Dec 15 '15 at 02:25
0

Here is an option that allows you to tailor the alignment of multiple choices and spread them to suit your needs:

enter image description here

\documentclass{article}

\usepackage{environ,enumitem,amsmath,xkeyval,expl3}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\newlist{question}{enumerate}{1}
\setlist[question]{label={\arabic*)}}

% http://tex.stackexchange.com/q/127005/5764
\makeatletter

\define@key{mc}{choices}{\setlength{\mchoicewidth}{\dimexpr\calc{1/#1}\linewidth}}
\define@boolkey{mc}{resume}[true]{}
\define@choicekey*{mc}{align}[\val\nr]{left,center,right}{%
  \expandafter\global\expandafter\let\expandafter\mc@align
  \ifcase\nr\relax% left
    \raggedright
  \or% center
    \centering
  \or% right
    \raggedleft
  \fi
}

\newcounter{multiplechoice}
\renewcommand{\themultiplechoice}{\Alph{multiplechoice}}
\NewEnviron{multiplechoice}[1]{%
  \par\nobreak
  \setkeys{mc}{choices=5,resume=false,align=left,#1}%
  \ifKV@mc@resume\else
    \setcounter{multiplechoice}{0}%
    \vspace{\bigskipamount}%
  \fi
  \setlength{\parindent}{0pt}%
  \def\item##1\item{\dosomething{##1}}%
  \expandafter\@empty\BODY\item}

\newlength{\mchoicewidth}
\newcommand{\dosomething}[1]{%
  \def\ampora@arg{#1}%
  \ifx\ampora@arg\ampora@stop
    \expandafter\env@ignore   % to end the recursion
  \else
    \refstepcounter{multiplechoice}%
    \begin{tabular}[t]{@{}p{\mchoicewidth}@{}}
      (\themultiplechoice)\nobreakspace
      \mc@align #1
    \end{tabular}%
    \expandafter\item         % to continue the recursion
  \fi
}

\edef\ampora@stop{\noexpand\env@ignore\space}
\makeatother

\begin{document}

\begin{question}
  \item Solve for $x$: $x = \cfrac{1}{2 - \cfrac{1}{2 + \cfrac{1}{2 - \cfrac{1}{2 + \ddots}}}}$
  \begin{multiplechoice}{}
    \item $\sqrt{2}$
    \item $\dfrac{\sqrt{5}-1}{2}$ %CORRECT
    \item $\dfrac{1+\sqrt{5}}{2}$
    \item $\dfrac{1}{\sqrt{3}}$
    \item NOTA
  \end{multiplechoice}

  \item Solve for $x$: $x = \cfrac{1}{2 - \cfrac{1}{2 + \cfrac{1}{2 - \cfrac{1}{2 + \ddots}}}}$
  \begin{multiplechoice}{choices=3,align=center}
    \item $\sqrt{2}$
    \item $\dfrac{\sqrt{5}-1}{2}$ %CORRECT
    \item $\dfrac{1+\sqrt{5}}{2}$
  \end{multiplechoice}
  \begin{multiplechoice}{choices=2,resume,align=center}
    \item $\dfrac{1}{\sqrt{3}}$
    \item \raggedleft NOTA
  \end{multiplechoice}
\end{question}

\end{document}

The multiplechoice environment provides a key-value mandatory argument where you can set the number of choices (default is 5), whether you want the environment numbering to resume from a previous one, as well as the generic alignment of each item. You can override individual items alignment as needed using, for example,

\begin{multiplechoice}{..}
\item ...
\item \raggedleft <some item>
\item ...
\end{multiplechoice}
Werner
  • 603,163