I am writing a book and I want the book to have Exercises at the end of each chapter and Solutions at the end. I'm using "xsim" to typeset the Exercises and Solutions.
I've started my MWE with an example file "xsim.texsx-576998", but in the MWE output (here), the instruction lines "In Exercise 1-2, ..." and "In Exercise 3-4, ..." don't show up at the place I want them to show up. I want them to show up like
In Exercise 1--2, solve for x.
1. x - 1 = 0
2. x^2 - 3x + 2 = 0
In Exercise 3--4, solve for y.
3. y^3 - 6 y^2 + 11 y - 6 = 0
4. y^4 - 10 y^3 + 35 y^2 - 50 y + 24 = 0
Questions
How can I make the Instructions appear between different exercises (see above)?
MWE
% TeXlive 2020
\documentclass[a4paper]{book}
\usepackage[margin=0.75in]{geometry}
\usepackage{lipsum}
\usepackage{xsim}
% -----from xsim.texsx-576998-----
\DeclareExerciseEnvironmentTemplate{number-only}{%
\par\noindent
\textbf{\GetExerciseProperty{counter}}%
\GetExercisePropertyT{subtitle}{ \textit{#1}} %
}{\par}
\newcommand\printsectionexercises{%
\ForEachUsedExerciseByType{%
\ifnum\ExercisePropertyGet{##1}{##2}{chapter-value}=\value{chapter}
\XSIMprint{exercise}{##1}{##2}%
\fi
}%
}
\renewcommand\printsolutions{%
\def\currentchapter{}%
\def\lastchapter{}%
\ForEachUsedExerciseByType{%
\let\lastchapter\currentchapter
\edef\currentchapter{\ExercisePropertyGet{##1}{##2}{chapter-value}}%
\ifx\lastchapter\currentchapter\else
\section*{Chapter \ExercisePropertyGet{##1}{##2}{chapter}}
\fi
\XSIMprint{solution}{##1}{##2}%
}%
}
\xsimsetup{
exercise/template = number-only ,
solution/template = number-only ,
exercise/within = section ,
exercise/the-counter = \arabic{exercise}. ,
exercise/print = false
}
\begin{document}
\chapter{ChapterOne}
\section{SectionOneOne}
\lipsum[1-1]
\noindent In Exercise 1--2, solve for \(x\).
\begin{exercise}
\(x - 1 = 0\)
\end{exercise}
\begin{solution}
\(x = 1\)
\end{solution}
\begin{exercise}
\(x^2 - 3x + 2 = 0\)
\end{exercise}
\begin{solution}
\(x = 1, 2\)
\end{solution}
\noindent In Exercise 3--4, solve for \(y\).
\begin{exercise}
\(y^3 - 6 y^2 + 11 y - 6 = 0\)
\end{exercise}
\begin{solution}
\(y = 1, 2, 3\)
\end{solution}
\begin{exercise}
\(y^4 - 10 y^3 + 35 y^2 - 50 y + 24 = 0\)
\end{exercise}
\begin{solution}
\(y = 1, 2, 3, 4\)
\end{solution}
\subsection*{Exercises}
\printsectionexercises
\chapter*{Solutions to the exercises}
\printsolutions
\end{document}