What I want seems pretty simple, but I was not able to find a satisfactory answer.
What I want is something like this
\section{Foo}
A bunch of definitions, theorems, remarks, etc.
\begin{exercise}
\ex\label{ex:foo:t1} Show that this is that.
\begin{ans}
This is that by casual observation.
\end{ans}
\ex Show that is this
\begin{ans}
Just reverse the answer to exercise \ref{ex:foo:t1}.
\end{ans}
\end{exercise}
The output should be something like:
1 Foo
A bunch of definitions, theorems, remarks, etc.
Exercises
Show that this is that.
Ans: This is that by casual observation.
Show that is this
Ans: Just reverse the answer to exercise 1.
I also need some flexibility in numbering. For example, with a few changes to the preamble, the output could be:
1 Foo
A bunch of definitions, theorems, remarks, etc.
Exercises For Section 1
1.1 Show that this is that.
Ans: This is that by casual observation.
1.2 Show that is this
Ans: Just reverse the answer to exercise 1.1.
exsheets
,answers
,probsoln
etc. can do this, I think\section{Foo}
because it depends on your class and on any packages you are using to customise the format of sectional headings.