[texhax] More exercises

James Smith sf at aleph-one.com
Fri Jun 15 11:04:18 CEST 2007


Axel, hi,

thanks, I'm familiar with the aptly named former, I'll download the
latter. In the end I hacked the exercise package and after several hours
work (and a fair few working man's expletives), I whittled it down to
the following, or something very like...

+++

\ProvidesPackage{exercise}

\newbox\@allAnswerBox

\newenvironment{Answer}{%
\newbox\@thisAnswerBox%
\global\setbox\@thisAnswerBox\vbox\bgroup%
}
{%
\egroup%
\newbox\@tempAnswerBox%
\global\setbox\@tempAnswerBox\vbox{\unvbox\@allAnswerBox\unvbox\@thisAns
werBox}%
\global\setbox\@allAnswerBox\copy\@tempAnswerBox%
}

\newcommand{\shipoutAnswer}{\unvbox\@allAnswerBox}

+++

The \bgroup command gives me what I want, the contents of the Answer
environment to copy to a vbox, but I have no idea what it means, or why
I need to invoke the corresponding \egroup command.

Solving this means I've got what I want, a little exercise package of
less than twenty lines that allows me to put answer environments inside
question environments and then spit them out at the end of each chapter.
The format and numbering of the questions follows very closely the
format of theorems and definitions so it looks okay to leave them in
situ within the text. It is surprising how important the look of the
exercises turns out to be. I guess this is what typsetting is all about.

Thanks to everyone who's helped me out on this.

Kind regards,

James

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.8.16/849 - Release Date:
14/06/2007 12:44
 



More information about the texhax mailing list