# How to create a column layout from a number of choices?

I am trying to create a command namely \twoc to make a simple two column answer space for a specific question. The output should appear like this:

While my code for the .tex file that I will be doing should only be like this using the command \twoc:

## Code

\Question What comes first?\\
\twoc
\text {apple}
\text {zebra}
\text {girrafe}
\text {dog}
\text {elephant}
\text {chicken}
\text {mouse}
\text {carabao}


## Note

The command \twoc will automatically divide the text choices even. Example if text choices that are made was 8 then there should be 4 in each column.

-

## migrated from meta.tex.stackexchange.comNov 5 '12 at 7:01

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

With a slightly different syntax, you can use the multicol environment from the multicol package within an enumerated list. The Question environment below accepts an optional first parameter to control the number of columns (defaults to a single column if not specified):

## Code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{etoolbox}
\usepackage{xstring}

\newtoggle{UseMulticolumns}
\newenvironment{Question}[2][1]{%
\IfEq{#1}{1}{%
\global\togglefalse{UseMulticolumns}%
}{%
\global\toggletrue{UseMulticolumns}%
}%
\begin{enumerate}[series=QuestionList,label=\arabic*.,resume=*]
\item #2
\begin{enumerate}[label={\protect\rule{1.0em}{0.5pt}}]
\iftoggle{UseMulticolumns}{\begin{multicols}{#1}}{}%
}{%
\iftoggle{UseMulticolumns}{\end{multicols}}{}%
\end{enumerate}%
\end{enumerate}%
}

\begin{document}
\begin{Question}{Which comes first?}
\item chicken
\item egg
\end{Question}
\begin{Question}[2]{What comes first?}
\item apple
\item zebra
\item girrafe
\item dog
\item elephant
\item chicken
\item mouse
\item carabao
\end{Question}
\begin{Question}[3]{Who shot first?}
\item Han
\item Greedo
\item Chewie
\end{Question}
\end{document}

-
when i build the code using Geany it did not compile. Instead, it underlines \begin{Question}{Which comes first?}. I changed the Question to questions already still it has errors. – Kayla Nov 5 '12 at 23:58
@kayla: I am not familiar with Geany, but if there was a compilation error, then it would be helpful to know what the error was. You probably need to update packages. If you are on an older release, I would recommend that you install TexLive 2012. – Peter Grill Nov 6 '12 at 0:32
i already installed TexLive in Ubuntu. But i compile my work(the aaa.tex) using the document class that i have made (the myclass) that when I use it \documentclass{myclass} and I use geany - a text editor to compile my latex file. I installed geany's plugin that supports latex in ubuntu so I can build or compile the file in geany rather than in terminal. – Kayla Nov 6 '12 at 12:18