# Multiple Choice Question type setting for options

In the following code we are getting answers of each questions in following ways [1] (a) (b) (c) (d) i.e. in (4-columns) [2] (a) (b) (c) (d) i.e. in (2-columns) according to the length of the answers. Its good....

Is there any correction in this code, if i want to produced all four options in a single column, i mean like (a) (b) (c) (d) (1-column) in my question bank there are lots of question having some good length of options and it is not possible to get output mentioned [1] and [2] forms.

Please provide some better solution for this code, i almost completed my works except few questions by using this code.

\documentclass[12pt,a4paper]{exam}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\setlength\parindent{0pt}
%usage \choice{ }{ }{ }{ }
%(A)(B)(C)(D)
\newcommand{\fourch}[4]{
\par
\begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
(a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
\end{tabular}
}

%(A)(B)
%(C)(D)
\newcommand{\twoch}[4]{

\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(a)~#1 & (b)~#2
\end{tabular}
\par
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(c)~#3 & (d)~#4
\end{tabular}
}

%(A)
%(B)
%(C)
%(D)
\newcommand{\onech}[4]{
\par
(a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4
}

\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth

\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}

\newcommand{\choice}[4]{%
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}%
\settowidth\widthchb{BM.#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchb{CM.#3}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchb{DM.#4}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\ifdim\widthch<\fourthtabwidth
\fourch{#1}{#2}{#3}{#4}
\else\ifdim\widthch<\halftabwidth
\ifdim\widthch>\fourthtabwidth
\twoch{#1}{#2}{#3}{#4}
\else
\onech{#1}{#2}{#3}{#4}
\fi
\fi\fi
}
\begin{document}
\begin{questions}
\question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram
representing az, 3az and - az are
\choice{Vertices of a right angled triangle}{ Vertices of an equilateral
triangle}{Vertices of an isosceles triangle}{Collinear}
\question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is
\choice{$\dfrac{\pi}{4}$}{$\dfrac{\pi}{2}$}{0}{$\dfrac{\pi}{6}$}
\question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
\choice{ purely imaginary}{purely real}{0}{neither real nor imaginary}
\question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
\choice{i}{-i}{1}{-1}
\question The volume generated by
rotating the triangle with vertices at
(0, 0), (3, 0) and (3, 3) about x-axis is
\choice{$18\pi$}{$2\pi$}{$36\pi$}{$9\pi$}\end{questions}
\end{document}

\end{document}


To get single-column answers the \ifdim sequence needs to be altered a little bit. The sequence should be: if the longest answer fits in 1/4, put four columns, else if the longest answer fits in 1/2 width, put 2 columns, else put 1 column.

Also, the length assignments for the four answers was incorrect (b is used for b,c, and d). MWE with these corrections:

\documentclass[12pt,a4paper]{exam}
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\setlength\parindent{0pt}
%usage \choice{ }{ }{ }{ }
%(A)(B)(C)(D)
\newcommand{\fourch}[4]{
\par
\begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
(a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
\end{tabular}
}

%(A)(B)
%(C)(D)
\newcommand{\twoch}[4]{

\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(a)~#1 & (b)~#2
\end{tabular}
\par
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(c)~#3 & (d)~#4
\end{tabular}
}

%(A)
%(B)
%(C)
%(D)
\newcommand{\onech}[4]{
\par
(a)~#1 \par (b)~#2 \par (c)~#3 \par (d)~#4
}

\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth

\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}

\newcommand{\choice}[4]{%
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}%
\settowidth\widthchb{BM.#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchc{CM.#3}%
\ifdim\widthch<\widthchc\relax\setlength{\widthch}{\widthchc}\fi%
\settowidth\widthchd{DM.#4}%
\ifdim\widthch<\widthchd\relax\setlength{\widthch}{\widthchd}\fi%
\ifdim\widthch<\fourthtabwidth
\fourch{#1}{#2}{#3}{#4}
\else\ifdim\widthch<\halftabwidth
\twoch{#1}{#2}{#3}{#4}
\else
\onech{#1}{#2}{#3}{#4}
\fi
\fi
}
\begin{document}
\begin{questions}
\question If $a = 3 + i$ and $z = 2 - 3i$ then the points on the Argand diagram
representing az, 3az and - az are
\choice{Vertices of a right angled triangle}{ Vertices of an equilateral
triangle}{Vertices of an isosceles triangle}{Collinear}
\question If z represents a complex number then $\arg (z) + \arg\left(\bar z\right)$ is
\choice{$\dfrac{\pi}{4}$}{$\dfrac{\pi}{2}$}{0}{$\dfrac{\pi}{6}$}
\question If the amplitude of a complex number is $\dfrac{\pi}{2}$ then the number is
\choice{ purely imaginary}{purely real}{0}{neither real nor imaginary}
\question The value of $i + i^{22} + i^{23} + i^{24} + i^{25}$ is
\choice{i}{-i}{1}{-1}
\question The volume generated by
rotating the triangle with vertices at
(0, 0), (3, 0) and (3, 3) about x-axis is
\choice{$18\pi$}{$2\pi$}{$36\pi$}{$9\pi$}
\question A question with very long answers
\choice{This answer is very long and will need the full width of the page to display which leads to a single column}{This answer, like the first, is very long and will need the full width of the page to display which leads to a single column}{This answer, like the second is very long and will need the full width of the page to display which leads to a single column}{This answer, like the third, is very long and will need the full width of the page to display which leads to a single column}
\end{questions}
\end{document}


Note that your MWE had two \end{document} statements.

Remark: the question was not entirely clear (I hope this solution is what you need). For future reference, please provide an example of what goes wrong, in this case a question with long answers.