在多项选择题测试中垂直对齐答案选项

在多项选择题测试中垂直对齐答案选项

我正在做一个多项选择微积分测试,并有以下代码。

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

但是,这会产生以下结果。请注意选项 A 垂直位于其他选项上方。

enter image description here

我该如何解决这个问题?请注意,我还将答案选项与其他问题的相应选项水平对齐,就像这样。

enter image description here

答案1

tasks包可以最简单地完成此操作:

\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

答案2

这是multicol环境 - 在包的文档中,multicol它说它尝试对齐基线,但是每列只有一行,显然很难做到这一点。

作为一种解决方法,添加一些不可见的东西,以便所有行具有相同的高度和深度,或者至少增加多列环境中每列第一行的高度。

例如

\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

答案3

您可以尝试使用enumitem带有水平列表选项的包inline来代替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

答案4

这里有一个选项,允许您定制多个选择的对齐方式并根据您的需要进行扩展:

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}

环境multiplechoice提供了一个键值强制的参数,您可以设置数字choices(默认为 5),是否希望环境编号来自resume前一个编号,以及每个项目的通用对齐方式。您可以根据需要使用以下方法覆盖单个项目的对齐方式:

\begin{multiplechoice}{..}
\item ...
\item \raggedleft <some item>
\item ...
\end{multiplechoice}

相关内容