3

I want to create Questions wherein each will include a series of fill in the blanks.

I want to display a worksheet which has an answer line in place of the answers. And then a worksheet where the answers are included over the answer line. And finally all the answers at the end.

What I'm aiming for:

Question worksheet with fill in the blanks. Questions

Question worksheet with blanks filled in Questions with Answers included

Answers only

enter image description here

I've looked at some packages like exercise, and exam but I don't think I can quite manipulate them to get what I'm after...

3

I've come up with a solution that does what I need. This might be helpful for anyone else. If anyone has other suggestions I'd be grateful as I'm just hacking around.

\documentclass[12pt,a4paper]{article}
\usepackage{ifthen}
\usepackage{tocloft}
\usepackage{exercise}
\usepackage{tasks}

% Set the Show Answers Boolean
\newboolean{showAns}
\setboolean{showAns}{false}
\newcommand{\showAns}{\setboolean{showAns}{true}}

% The length of the Answer line
\newlength{\answerlength}
\newcommand{\anslen}[1]{\settowidth{\answerlength}{#1}}

% ans command that indicates space for an answer or shows the answer in red
\newcommand{\ans}[1]{\settowidth{\answerlength}{\hspace{2ex}#1\hspace{2ex}}%
    \ifthenelse{\boolean{showAns}}%
        {\textcolor{red}{\underline{\hspace{2ex}#1\hspace{2ex}}}}%
        {\underline{\hspace{\answerlength}}}}%

% Formatting how multiple choices Questions are formated.
\settasks{counter-format={tsk[A].}}


% Some commands for the Exercise Question package
\renewcommand{\QuestionNB}{\Large\protect\textcircled{\small\bfseries\arabic{Question}}\ }
\renewcommand{\ExerciseHeader}{} %no header
\renewcommand{\QuestionBefore}{3ex} %Space above each Q
\setlength{\QuestionIndent}{8pt} % Indent after Q number


% To create the list of answers with tocloft... 
\newcommand{\listanswername}{Answers}
\newlistof[Question]{answer}{Answers}{\listanswername}

% Creates a TOC for Answers
\newcounter{prevQ}
\newcommand{\answer}[1]{\refstepcounter{answer}%
\ans{#1}%
\ifnum\theQuestion=\theprevQ%
        \addcontentsline{Answers}{answer}{\protect\numberline{}#1}% don't include the Q number
        \else%
        \addcontentsline{Answers}{answer}{\protect\numberline{\theQuestion}#1}%
        \setcounter{prevQ}{\value{Question}}%
        \fi%
        }%


%tocloft formatting listofanswers
\renewcommand{\cftAnswerstitlefont}{\bfseries\large}
\renewcommand{\cftanswerdotsep}{\cftnodots}
\cftpagenumbersoff{answer} 
\addtolength{\cftanswernumwidth}{10pt}


\begin{document}

\showAns

\begin{Exercise}
\Question $1+2$ is (\answer{C})
\begin{tasks}(4)
\task 1
\task 2
\task 3
\task 4
\end{tasks}

\Question $2+3=$~\answer{$5$}

\Question A question might have multiple places for the answer. The first answer is \answer{This is the answer}. The second answer is \answer{this is the other answer}.

\end{Exercise}
%Now just the answers

\listofanswer


\end{document}

Here's what the code produces without \showAns Question with spaces

with \showAns Question with Answers

And the tocloft package produces this for \listofanswer

answers only

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.