2

I would do with xsim, successor of exsheets, the same I do with it: lists of questions inside a tasks environment.

Is that possible?

Something like this:

\documentclass{article}
\usepackage{exsheets, tasks}

\makeatletter
\def\sol{\relax}
\newcommand*{\@exoSol}[1]{%
\ES@Line #1 \sol\sol%
}

\ExplSyntaxOn
\cs_set_eq:NN \exsheets_par: \scan_stop:
\ExplSyntaxOff

\SetupExSheets{
  headings=inline-nr,
  counter-format=$\cdot$qu$\cdot$,
  question/no-skip-below = true,
  question/post-hook={},
  solution/post-hook={\hspace{1em}},
  solution/pre-hook={}
  }

\long\def\ES@Line#1\sol#2\sol{%
\begin{question}#1\end{question}%
\long\def\@test{#2}\ifx\@test\empty\else\begin{solution}#2                    
\end{solution}\fi%

}


\NewTasks[
   label={\relax},
   label-width=0em,
   item-indent=0em,
   label-offset=0em,
   item-format={\@exoSol},
   before-skip = 0pt]{series}[?]
\makeatother

\begin{document}

Solve with natural numbers, when possible:
\begin{series}(3)
  ? $1+5$ \sol $6$
  ? $4-2$ \sol $2$
  ? $3-4$ \sol impossible
  ? $8+2$ \sol $10$
  ? $0+0$
  ? $6\times 0$ \sol $0$
\end{series}

Solutions:\par
\printsolutions

\end{document}

example with exsheets

1

Here is a solution using up to date versions of tasks (2020/01/11 v1.1a) and xsim (2020/02/21 v0.17). It needs xsim to be loaded with the no-files option in order to use the environments inside of other macros. It also utilizes \ifblank from the etoolbox package (which is loaded, anyway) for the sake of convenience.

First I slightly change your custom macros (mostly as a matter of taste):

\newcommand*\sol{}
\newcommand*\exsol[1]{\ESLine#1\sol\sol}
\long\def\ESLine#1\sol#2\sol{%
  \begin{exercise}#1\end{exercise}%
  \ifblank{#2}{}{\begin{solution}#2\end{solution}}%
}

Now I define a suitable template for exercises and solutions (note the spaces, they are significant):

\DeclareExerciseEnvironmentTemplate{dotted}
  {\textbf{$\cdot$\GetExerciseProperty{counter}$\cdot$} }
  { }

Then I tell xsim to use the new template and to omit the heading of \printsolutions:

\xsimsetup{
  exercise/template = dotted ,
  solution/template = dotted ,
  print-solutions/headings = false
}

And at last I define the tasks environment with an empty label, the numbering comes from xsim:

\NewTasksEnvironment[
  label =  ,
  label-width = 0em ,
  item-indent = 0em ,
  label-offset = 0em ,
  item-format = \exsol
]{series}[?]

That's it. The document body is the same as in the OP.

enter image description here

The complete code:

\documentclass{article}
\usepackage[no-files]{xsim}[2020/02/21]
\usepackage{tasks}

\newcommand*\sol{}
\newcommand*\exsol[1]{\ESLine#1\sol\sol}
\long\def\ESLine#1\sol#2\sol{%
  \begin{exercise}#1\end{exercise}%
  \ifblank{#2}{}{\begin{solution}#2\end{solution}}%
}

\DeclareExerciseEnvironmentTemplate{dotted}
  {\textbf{$\cdot$\GetExerciseProperty{counter}$\cdot$} }
  { }

\xsimsetup{
  exercise/template = dotted ,
  solution/template = dotted ,
  print-solutions/headings = false
}

\NewTasksEnvironment[
  label =  ,
  label-width = 0em ,
  item-indent = 0em ,
  label-offset = 0em ,
  item-format = \exsol
]{series}[?]

\begin{document}

Solve with natural numbers, when possible:
\begin{series}(3)
  ? $1+5$ \sol $6$
  ? $4-2$ \sol $2$
  ? $3-4$ \sol impossible
  ? $8+2$ \sol $10$
  ? $0+0$
  ? $6\times 0$ \sol $0$
\end{series}

Solutions:\par
\printsolutions

\end{document}

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.