# How to embed \choices in tabular in exam class?

Similar to the question: Exam class multiple choice answers in table format, I'm trying to embed the \choices into a table format and looking like a table.

\documentclass[11pt]{exam}
\usepackage{mathtools}
\usepackage{xspace}
\usepackage{array}
\usepackage{tikz}
\newcommand{\wideunderline}[2][2em]{%
\underline{\makebox[\ifdim\width>#1\width\else#1\fi][c]{#2}}%
}
\begin{document}

\fbox{\parbox{\linewidth}{
When compared to the graph of $y=f(x)$, the graph of $8y=f(-x)$ has been reflected in the \wideunderline[1.5cm]{\textit{i}} and vertically stretched about the x-axis by a factor of \wideunderline[1.5cm]{\textit{ii}}}}\medskip
\begin{questions}
\question The statement above is completed by the information in row:\medskip

\begin{choices}
\renewcommand\arraystretch{1.5}
\choice A
\correctchoice B
\choice C
\choice D
\end{choices}

\question I want choice B embedded in the table.
%\begin{choices}%%%is this possible?
\begin{tabular}{|c|c|c|}
\hline
\textbf{Row }& \textbf{\textit{i}}&\textbf{\textit{ii}}\\
\hline
A &  $y$-axis&8\\
\hline
B &  $y$-axis&$\frac{1}{8}$\\%I would like the choice to be embeded i.e. \choice B is in the first column of the table in row 3.
\hline
C &  $x$-axis&8\\
\hline
D &  $x$-axis&$\frac{1}{8}$\\
\hline
\end{tabular}
%\end{choices}%%%%doesn't work.
\end{questions}
\end{document}

Can anyone help me with this?

• What is the difference between your problem and linked post? – user108724 Sep 29 at 19:57
• I guess there is no difference. Since it wasn't answered, I thought I would ask my own question. Sorry, still new at stack exchange protocol. – E.Yu Sep 30 at 3:08
• I want to know what does it means "embed \choices into a table format and looking like a table"? This means that a 4x2 table that the choices answers sit in the first column of table? – user108724 Sep 30 at 5:42

The oneparchoices environment almost does what you want but it has two major limitations: First, embedding the choices in a table messes up the handling for \correctchoice and second, the formatting automatically adds extra space before each \choice after the first which makes sense in the paragraph situation but otherwise not so much.

To get something approaching what you want, I modified the oneparchoices environment to remove horizontal spacing and only apply the correct choice formatting to the label rather than the whole answer (which would be challenging to do in a generalizable way given the fact that we're putting the \choice commands into cells of a table.

Here's the new environment definition:

\makeatletter
\newenvironment{noparchoices}%
{%
\setcounter{choice}{0}%
\def\choice{%
\refstepcounter{choice}%
\choicelabel
% No need to put the following into a token string; we just put
% the choicelabel onto the page, so we're at the spot whose page
% number we want to record:
\questionobject@pluspagecheck
}% choice
\def\CorrectChoice{%
\refstepcounter{choice}%
\begingroup
\CorrectChoice@Emphasis
\fi
\choicelabel
\endgroup
% No need to put the following into a token string; we just put
% the choicelabel onto the page, so we're at the spot whose page
% number we want to record:
\questionobject@pluspagecheck
}% CorrectChoice
\let\correctchoice\CorrectChoice
% If we're continuing the paragraph containing the question,
% then leave a bit of space before the first choice:
\ignorespaces
}%
{}
\makeatother

and here's an example of its use:

\begin{noparchoices}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Row }& \textbf{\textit{i}}&\textbf{\textit{ii}}\\
\hline
\choice &  $y$-axis&8\\
\hline
\correctchoice &  $y$-axis&$\frac{1}{8}$\\
\hline
\choice &  $x$-axis&8\\
\hline
\choice &  $x$-axis&$\frac{1}{8}$\\
\hline
\end{tabular}
\end{noparchoices}