[Tex/LaTex] How to produce exercises in one part of a LaTeX document with selected answers in another

exercises

How can I produce exercises in one part of a LaTeX document with selected answers in another? I could, of course, simply typeset the questions and the answers separately, but this is too likely lead to divergence in the labels for the questions and the answers as the document is edited.

What I'd really like is a command that would allow me to typeset exercises at the point at which the command was used and which took an optional argument for a solution to be stored until a final section (chapter, or part) "Selected Exercise Answers". I'd like the questions (and the selected answers) to be labeled in the output by Chapter.Section.Question or even Chapter.Question.

Best Answer

You can use the exam document class in both your documents. Then refer to chapter 8: including solutions.

Basically, anywhere in the document you can just specify \printanswers or \noprintanswers or use the answers option when loading the document class.

It’s easiest if you have the actual questions and answers in a separate document that you \input into both the exercise document and the sample solution document.

If you want an extra section with the answers, you could instead \input the questions document twice, once before and once after the \printanswers document: this will cause the first appearance of the questions to be printed without answers, and the second appearance with answers.

Related Question