Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following code gives a way to produce Multiple Choices Questions. This solution comes from here.

I would like to have the possibility to display the choices in 2 or 3 columns by giving one optional argument. Is there a way to do that ?

\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}
share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

Not exactly what you're looking for, but approximately as easy to use. A choice environment and command is probably overkill compared to customizing an enumerated list with the enumitem package (reworked from earlier version to match preferred semantics):

enter image description here

\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}
share|improve this answer
    
Thanks for this begin of solution. I prefer to use one special environment for semantic reasons. –  projetmbc Mar 3 '12 at 22:47
    
Reworked to match your semantics. –  Mike Renfro Mar 4 '12 at 1:30
    
Thanks for this modification, that's great ! –  projetmbc Mar 4 '12 at 8:53
    
@MikeRenfro How to make it numbering along the rows rather than numbering down the columns? Thanks. –  Z.H. Oct 4 '13 at 8:57
    
If all the answers can fit on one line, you could just increase the number of columns in the multicol environment. The only other easy way (for me) would be to use enumitem's inline list options. You won't get a row/column layout with that, though. There may be some TikZ routes, or someone might have a way of building a table one cell at a time, automatically inserting row breaks as needed. If that's more of what you need, I'd say it's worth asking a separate question. –  Mike Renfro Oct 5 '13 at 13:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.