TeX - LaTeX Asked by E.Yu on February 3, 2021
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}
printanswers
newcommand{wideunderline}[2][2em]{%
underline{makebox[ifdimwidth>#1widthelse#1fi][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}
renewcommandarraystretch{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?
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}%
defchoice{%
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
defCorrectChoice{%
refstepcounter{choice}%
ifprintanswers
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
letcorrectchoiceCorrectChoice
% 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}
Answered by Don Hosek on February 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP