tags:

views:

99

answers:

2

I'm writing a book and want to add some math problems and solutions to this book. Is it possible to have the following in LaTeX?

  1. In the LaTeX source file, the source of the solution will be directly after the problem.
  2. In the typeset book, the section with solutions will be typeset at the end.
+1  A: 

You can put material at the end of the document (regardless of its location in the source) with \AtEndDocument{...}.

Incorporating that into your macro for writing questions/answers is left as an exercise :)

Will Robertson
I think it's a rather hard exercise. Could you elaborate? What if you want to have an index (for instance) to appear after the solutions?
ShreevatsaR
Write `\AtEndDocument{\PrintIndex}` at the end of your document.
Will Robertson
+4  A: 

There's a package called answers which appears to do something like this (do texdoc answers, or the equivalent on your platform, for the documentation).

If that doesn't work, or isn't really suitable, then I've got a hand-rolled solution to exactly this problem which I could post here.

Norman Gray
Always good to use a pre-existing package where possible. +1
Will Robertson