# Exsheets: print solutions per section fails

I'm using the exsheets package to write exercises and solutions in a textbook. My purpose is to list some exercises at the end of each section followed by their corresponding solutions, as intended in the following MWE:

\documentclass[12pt,a4paper]{book}
\usepackage{exsheets}

\begin{document}
\chapter{Chapter A}

\section{Section A}\exlabel{sec:AA}

\subsection{Subsection A}

\subsection*{Exercises}

\begin{question}
Question 1.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[section=\S{sec:AA}]

\chapter{Chapter B}

\section{Section A}\exlabel{sec:BA}

\subsection{Subsection A}

\subsection*{Exercises}

\begin{question}
Question 2.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[section=\S{sec:BA}]

Solution 1 shouldn't appear twice!

\end{document}


My Problem is, that the solutions of the previous sections (with the same number of the current section) reappear after a new chapter. That means especially for the MWE: Solution 1 is printed both in chapter A section A and in chapter B section A. How can I avoid this? Do I miss something? Reading the Documentation didn't help.

Remarks: I use exlabel because of hyperref in my original document. Also, I could easly use my own environments instead of exsheets. But I want to be flexible, if I decide to print all solutions at the end of my document.

You're missing a pair of braces:

\printsolutions[section={\S{sec:AA}}]


But unfortunately I didn't foresee the wish to print solutions section-wise in a document with chapters so this won't work... (you could make a feature request on Bitbucket, though :) ). The problem will be that in different chapters sections have the same section numbers so with the current implementation for example all solutions for exercises from a section with counter value 2 would be included with \printsolutions[section=2] ...

If you only have one solution section per chapter then

\printsolutions[chapter]


would do:

\documentclass[12pt,a4paper]{book}
\usepackage{exsheets}

\begin{document}
\chapter{Chapter A}
\section{Section A}
\subsection{Subsection A}
\subsection*{Exercises}

\begin{question}
Question 1.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[chapter]

\chapter{Chapter B}
\section{Section A}
\subsection{Subsection A}
\subsection*{Exercises}

\begin{question}
Question 2.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[chapter]

\end{document}


The only alternative for the time being is to assign ID's to the questions and print the solutions by ID.

\documentclass[12pt,a4paper]{book}
\usepackage{exsheets}

\begin{document}
\chapter{Chapter A}
\section{Section A}
\subsection{Subsection A}
\subsection*{Exercises}

\begin{question}[ID=AA]
Question AA.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[byID={AA}]

\section{Section B}
\subsection{Subsection B}
\subsection*{Exercises}

\begin{question}[ID=AB]
Question AB.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[byID={AB}]

\chapter{Chapter B}
\section{Section A}
\subsection{Subsection A}
\subsection*{Exercises}

\begin{question}[ID=BA]
Question BA.
\end{question}
\begin{solution}
\end{solution}

\subsection*{Solutions}
\printsolutions[byID={BA}]

\section{Section B}
\subsection{Subsection B}
\subsection*{Exercises}

\begin{question}[ID=BB]
Question BB.
\end{question}
\begin{solution}