TeX - LaTeX Asked by Christian Michell on February 20, 2021
I can’t find any place where I can get an exam environment where I can make a multiple choice exam with circle checkbox where the options are in letters A,B,C,D and E, and these are inside the checkboxes. Please help…
Using some Tikz trickery it can be done. If you are using oneparcheckboxes
, all you have to do is modify the checkboxchar
and checkedchar
commands:
% Make checkbox character a circle with the letter
checkboxchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {thechoice};}
% Make checked box character bold WITH surd
%checkedchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {thechoicellap{$surd$}};}
% Make checked box character bold
checkedchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {thechoice};}
But this will not work for the checkboxes
environment because it does not keep track of the items using a counter. For that, you have to modify the environment:
makeatletter
renewenvironment{checkboxes}%
{setcounter{choice}{0}list{checkbox@char}%
{%
settowidth{leftmargin}{W.hskiplabelsephskip 2.5em}%
defchoice{%
if@correctchoice
color@endgroup endgroup
fi
stepcounter{choice}
item[checked@char]
do@choice@pageinfo
} % choice
defCorrectChoice{%
if@correctchoice
color@endgroup endgroup
fi
ifprintanswers
% We can't say choice here, because that would
% insert an endgroup.
% 2016/05/10: We say color@begingroup in addition to
% begingroup in case CorrectChoiceEmphasis involves color
% and the text exactly fills the line (which would
% otherwise create a blank line after this choice):
% 2016/05/11: We leave hmode if we're in it,
% i.e., if there's no blank line preceding this
% CorrectChoice command. (Without this, the
% special created by a color{whatever} command that might
% be inserted by CorrectChoice@Emphasis would be appended
% to the previous choice, which could cause an extra
% (blank) line to be inserted before this CorrectChoice.)
% Since par and endgraf seem to cancel @totalleftmargin
% (for reasons I don't understand), we'll do the following:
% Motivated by the def of leavevmode,
% defleavevmode{unhboxvoidb@x}
% we will now leave hmode (if we're in hmode):
ifhmode unskipunskipunvboxvoidb@x fi
begingroup color@begingroup @correctchoicetrue
CorrectChoice@Emphasis
stepcounter{choice}
item[checked@char]
else
stepcounter{choice}
item[checked@char]
fi
do@choice@pageinfo
} % CorrectChoice
letcorrectchoiceCorrectChoice
labelwidthleftmarginadvancelabelwidth-labelsep
topsep=0pt
partopsep=0pt
checkboxeshook
}%
}%
{if@correctchoice color@endgroup endgroup fi endlist}
makeatother
And now for a MWE:
documentclass[a4paper,12pt,answers]{exam}
usepackage{tikz}
makeatletter
renewenvironment{checkboxes}%
{setcounter{choice}{0}list{checkbox@char}%
{%
settowidth{leftmargin}{W.hskiplabelsephskip 2.5em}%
defchoice{%
if@correctchoice
color@endgroup endgroup
fi
stepcounter{choice}
item[checked@char]
do@choice@pageinfo
} % choice
defCorrectChoice{%
if@correctchoice
color@endgroup endgroup
fi
ifprintanswers
% We can't say choice here, because that would
% insert an endgroup.
% 2016/05/10: We say color@begingroup in addition to
% begingroup in case CorrectChoiceEmphasis involves color
% and the text exactly fills the line (which would
% otherwise create a blank line after this choice):
% 2016/05/11: We leave hmode if we're in it,
% i.e., if there's no blank line preceding this
% CorrectChoice command. (Without this, the
% special created by a color{whatever} command that might
% be inserted by CorrectChoice@Emphasis would be appended
% to the previous choice, which could cause an extra
% (blank) line to be inserted before this CorrectChoice.)
% Since par and endgraf seem to cancel @totalleftmargin
% (for reasons I don't understand), we'll do the following:
% Motivated by the def of leavevmode,
% defleavevmode{unhboxvoidb@x}
% we will now leave hmode (if we're in hmode):
ifhmode unskipunskipunvboxvoidb@x fi
begingroup color@begingroup @correctchoicetrue
CorrectChoice@Emphasis
stepcounter{choice}
item[checked@char]
else
stepcounter{choice}
item[checked@char]
fi
do@choice@pageinfo
} % CorrectChoice
letcorrectchoiceCorrectChoice
labelwidthleftmarginadvancelabelwidth-labelsep
topsep=0pt
partopsep=0pt
checkboxeshook
}%
}%
{if@correctchoice color@endgroup endgroup fi endlist}
makeatother
% Make checkbox character a circle with the letter
checkboxchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {thechoice};}
% Make checked box character bold WITH surd
%checkedchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {thechoicellap{$surd$}};}
% Make checked box character bold
checkedchar{tikz[baseline={([yshift=-.8ex]current bounding box.center)}]node[shape=circle,minimum size=8mm,draw] at (0,0) {} node at (0,0) {thechoice};}
begin{document}
begin{questions}
question
Blah blah
begin{checkboxes}choice one
choice two
CorrectChoice three
end{checkboxes}
question
Blah blah
begin{oneparcheckboxes}
choice one
choice two
CorrectChoice three
end{oneparcheckboxes}
end{questions}
end{document}
This will shows as:
Correct answer by Jesse op den Brouw on February 20, 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