I am writing some notes which contains question of multiple choice options, each question has 4 options out of which 0,1,2,3, or 4 options may be correct. I am using tasks package for wring options. (I am not using any class because its a type of book and I am using tasks package because I want some options to print in two columns with horizontal labeling.)
The problem I am having is I want to have a correct/true choice option in there and want to display answers at end of each section. I am not able to define a correct/true choice options and not able to print them at the end. I have seen all the questions regarding this but they dont have what I am looking for.
Please help me
The code I have is
\documentclass{article}
\usepackage{endnotes}
\usepackage{tasks}
\NewTasksEnvironment[style=enumerate, counter-format=($\alph*$),label-width=4ex,item-indent =2em,label-offset=0em]{choices}[\choice](1)
\NewTasks[style=enumerate, counter-format=($\alph*$),label-width=4ex,item-indent =2em,label-offset=0em]{choices2}[\choice](2)
\NewTasks[style=enumerate, counter-format=($\alph*$),label-width=4ex,item-indent =2em,label-offset=0em]{choices4}[\choice](4)
% Define two new counters for ease of using.
\newcounter{questionnumber}
\newcounter{choicenumber}[questionnumber]
% Formatting the counters, this is where you change how the counters
% appear.
\renewcommand*\thequestionnumber{\arabic{questionnumber}.}
\renewcommand*\thechoicenumber{\alph{choicenumber})}
% Define the \question and \choice commands to be similar to what is
% given in the OP
\newcommand*\question{\item}
%\newcommand*\choice{\item}
% Here's a bit of a hack: \endnotetext stores the \meaning of the its argument
% in the endnotetext file, so the macros aren't expanded. I use \edef to fully
% expand the current \thechoicenumber, and use \expandafter to stuff it into
% the argument for \endnotetext. Suggestions for improvements are welcome!
\newcommand*\entreplace[1]{\endnotetext[\value{questionnumber}]{#1}}
\newcommand\truechoice[2]{\item #1 \edef\tempchoice{\thechoicenumber} \expandafter\def\expandafter\currentcount\expandafter{\tempchoice \ \ #2} \expandafter\entreplace\expandafter{\currentcount}}
% Define a choices environment, just a list basically.
%\newenvironment{choices}{\begin{tasks}{\thechoicenumber}{\usecounter{choicenumber}}}{\end{tasks}}
% These are to set up the endnotes. The first makes the endnote marks look
% like the question numbering (as opposed to being in superscript). The second
% sets the endnotes heading to read "Answers".
\renewcommand*\makeenmark{\theenmark.~~}
\renewcommand*\notesname{Answers:}
\begin{document}
\section{Section 1}
\begin{list}{\thequestionnumber}{\usecounter{questionnumber}}
\question Some question
\begin{choices}
\truechoice{True choice}{}
\choice False choice
\choice Bad choice
\choice Bad choice
\end{choices}
\end{list}
% Print the "answers"
\theendnotes
\section{Section 2}
\begin{list}{\thequestionnumber}{\usecounter{questionnumber}}
\question Some question
\begin{choices2}
\choice False choice
\truechoice{True choice}{}
\choice Bad choice
\choice Bad choice
\end{choices2}
\end{list}
% Print the "answers"
\theendnotes
\section{Section 3}
\begin{list}{\thequestionnumber}{\usecounter{questionnumber}}
\question Some question
\begin{choices4}
\choice False choice
\choice Bad choice
\truechoice{True choice}{}
\choice Bad choice
\end{choices4}
\end{list}
% Print the "answers"
\theendnotes
\end{document}
This is what I get