0

I'm working on a math book with exercises interspersed within the running text. I have an ex environment for these exercises and a sol environment for the solutions. The solutions reside in an appendix at the end of the book. The book is pretty big already and distributed over 40+ files.

Right now, whenever I add an exercise, I add the corresponding solution to the appendix, but I have to make sure the order of solutions in the appendix corresponds to the order of exercises in the book. I have rearranged the order of some chapters a few times and that always was a PITA as I had to manually move the solutions around.

Is there a library similar to something like endnotes that would allow me to put each solution directly after the corresponding exercise in the source with the outcome that in the final document the solutions would all be moved to their own chapter at the end of the text?

(I'm afraid I couldn't find a meaningful tag for this question. Maybe someone else can.)

  • 2
    Packages probsoln, answers, exsheet ... all do such kind of things – user31729 Feb 6 '17 at 17:26
  • 2
    You could also have a look at collect, mentioned in How to collect text for later usage in appendix? and How to place all proofs automatically in appendix? – ebosi Feb 6 '17 at 17:55
  • Damn, collect looked as if it were exactly what I was looking for, but it turns out it doesn't work together with fancyvrb which I'm using in many solutions. Hmm... – Frunobulax Feb 6 '17 at 20:07
  • 1
    I would hazard a guess that neither collect nor fancyvrb are really at fault here. In *TeX, verbatim (and by extension, fancyvrb) breaks when placed inside pretty much anything. See the FAQ – Fox Feb 6 '17 at 23:15
  • FWIW, I'm now using answers as suggested by @ChristianHupfer and that seems to work fine with fancyvrb. The difference is that collect somehow pre-digests the text it collects and strips off all whitespace while answers writes the contents to file as is. – Frunobulax Feb 7 '17 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.