In preamble:
\usepackage{answers}
%Exercise:
\newtheorem{Exc}{Exercise}[subsection]
%exercise without answer:
\newenvironment{ex}{\begin{Exc}\normalfont}{\end{Exc}}
%exercise with answer in appendix:
\newenvironment{exw}{\begin{Exc}%
\Writetofile{answers}{\textbf{\thesubsection.\arabic{Exc}}}%
$\dagger$\normalfont}{\end{Exc}}
\Newassociation{sol}{Solution}{answers}
\renewcommand{\Solutionlabel}[1]{\null}% suppresses the label
At the start of the document:
\begin{document}
\Opensolutionfile{answers}[exanswers]
In the text:
1. An exercise without a solution:
\begin{ex} Show that
$f(A_1\cup A_2)= f(A_1)\cup f(A_2)$.
\end{ex}
1.2.3.1 Exercise Show that ...
where 1.2.3 is the subsection number, and this is the first exercise in that subsection. The "1.2.3.1 Exercise" will be in bold, and the rest in the ambient normalfont of the document.
2. An exercise with a solution:
\begin{exw} Write out the proofs of all the
remaining identities in the Proposition.
\end{exw}
\begin{sol}
Hint: Imitate the proof given for the first one.
\end{sol}
-- This will set the exercise with a label like
1.2.3.2 Exercise $dagger$ Write out ...
where 1.2.3 is the subsection number and this is the second exercise in it. $dagger$ will print as a dagger, flagging the fact that there is a solution given later. The 1.2.3.2 and the material in the sol environment will be enclosed in a Solution environment and written out to the file exanswers.tex.
Finally, at the point where answers are to appear in the appendix:
\Closesolutionfile{answers}
\input{exanswers.tex}
No comments:
Post a Comment