TeX - LaTeX Asked on January 3, 2022
How to print the solution of multiple choice question in the following example ?
documentclass{scrartcl}
usepackage[clear-aux]{xsim}
usepackage{enumitem,amssymb,fmtcount}
newlist{choices}{itemize}{1}
setlist[choices]{label=$Box$}
newcommand*choice{item}
DeclareExerciseProperty{choices}
DeclareExerciseProperty*{multiple}
DeclareExerciseEnvironmentTemplate{mc}
{%
UseExerciseTemplate{begin}{default}%
IfExerciseBooleanPropertyTF{multiple}
{Select one or more correct answers}
{%
GetExercisePropertyT{choices}
{Select numberstringnum{#1} correct answerifnum#1>1 sfi.}%
}%
begin{choices}
}
{%
end{choices}
UseExerciseTemplate{end}{default}%
}
DeclareExerciseType{mc}{
exercise-env = multiplechoice ,
solution-env = correctchoices ,
exercise-name = Question ,
solution-name = Solution ,
exercise-template = mc ,
solution-template = mc ,
counter = exercise
}
xsimsetup{
exercise/name = Question ,
solution/name = Solution
}
begin{document}
section{Questions}
begin{multiplechoice}[choices=1]
choice one
choice two
choice three
choice four
end{multiplechoice}
begin{exercise}
Answer this question on a separate sheet.
end{exercise}
begin{multiplechoice}[multiple]
choice one
choice two
choice three
choice four
end{multiplechoice}
begin{multiplechoice}[choices=2]
choice one
choice two
choice three
choice four
end{multiplechoice}
end{document}
I tried with
%preamble
exercise/print = true,
solution/print = true,
%document
begin{correctchoices}
choice two
end{correctchoices}
But it is giving odd output.
Also, is it possible to mark the answer on the question itself while printing solution?
Starting with version 0.17 (2020/02/21) xsim
has the exercise property solution
which tells xsim
to use the same environment body for the exercise and the solution. This is very convenient here. Using IfInsideSolutionTF
then allows us to insert the checkmark where needed:
documentclass{scrartcl}
usepackage{xsim}[2020/02/21]
usepackage{enumitem,fontawesome,fmtcount,multicol}
newlist{choices}{itemize}{1}
setlist[choices]{label=faSquareO}
newcommand*correct{IfInsideSolutionTF{faCheckSquareO}{faSquareO}}
newcommand*choice{item}
DeclareExerciseProperty{choices}
DeclareExerciseProperty*{multiple}
DeclareExerciseEnvironmentTemplate{mc}
{%
UseExerciseTemplate{begin}{default}%
IfExerciseBooleanPropertyTF{multiple}
{Select one or more correct answers}
{%
GetExercisePropertyT{choices}
{Select numberstringnum{#1} correct answerifnum#1>1 sfi.}%
}%
begin{choices}
}
{%
end{choices}
UseExerciseTemplate{end}{default}%
}
DeclareExerciseType{mc}{
exercise-env = multiplechoice ,
solution-env = correctchoices ,
exercise-name = Question ,
solution-name = Solution ,
exercise-template = mc ,
solution-template = mc ,
counter = exercise
}
xsimsetup{
exercise/name = Question ,
solution/name = Solution ,
print-solutions/headings=false
}
begin{document}
begin{multicols}{2}
section{Questions}
begin{multiplechoice}[choices=1,solution]
choice one
choice[correct] two
choice three
choice four
end{multiplechoice}
begin{exercise}
Answer this question on a separate sheet.
end{exercise}
begin{multiplechoice}[multiple,solution]
choice[correct] one
choice two
choice three
choice[correct] four
end{multiplechoice}
begin{multiplechoice}[choices=2,solution]
choice one
choice[correct] two
choice three
choice[correct] four
end{multiplechoice}
columnbreak
section{Answers}
printsolutions
end{multicols}
end{document}
Answered by cgnieder on January 3, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP