2 列或 3 列的多项选择题

2 列或 3 列的多项选择题

以下代码提供了一种生成多项选择题的方法。此解决方案来自这里

我希望能够通过提供一个可选参数来将选项显示为 2 列或 3 列。有办法吗?

\documentclass[a4,12pt]{article}
    \usepackage[utf8x]{inputenc}
    \usepackage{amsmath}

    \newcounter{choice}
    \renewcommand\thechoice{\Alph{choice}}
    \newcommand\choicelabel{\thechoice)}

    \newenvironment{choice}{%
        \list{\choicelabel}{%
            \usecounter{choice}\def\makelabel##1{\hss\llap{##1}}%
            \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%
            \def\choice{%
                \item
            } % choice
            \labelwidth\leftmargin\advance\labelwidth-\labelsep
            \topsep=0pt
            \partopsep=0pt
        }%
    }{\endlist} 

\begin{document}
Which fractions are reduced ?

\begin{choice}
    \choice $\dfrac{4}{7}$
    \choice $\dfrac{8}{24}$
    \choice $\dfrac{44}{121}$
    \choice $\dfrac{9}{11}$
\end{choice}

\end{document}

答案1

不完全是您想要的,但使用起来也差不多。与使用枚举项包(根据早期版本重新设计以匹配首选语义):

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{multicol}

\newlist{choices}{enumerate}{1}
\setlist[choices]{label*=(\Alph*)}
\newcommand{\choice}{\item}

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

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

\begin{document}
Which fractions are reduced (one column)?
\begin{choices}
   \choice $\dfrac{4}{7}$
   \choice $\dfrac{8}{24}$
   \choice $\dfrac{44}{121}$
   \choice $\dfrac{9}{11}$
\end{choices}

Which fractions are reduced (two columns)?
\begin{choices}[twocol]
   \choice $\dfrac{4}{7}$
   \choice $\dfrac{8}{24}$
   \choice $\dfrac{44}{121}$
   \choice $\dfrac{9}{11}$
\end{choices}

Which fractions are reduced (three columns)?
\begin{choices}[threecol]
   \choice $\dfrac{4}{7}$
   \choice $\dfrac{8}{24}$
   \choice $\dfrac{44}{121}$
\end{choices}

\end{document}

相关内容