I would like to be able to generate a latex document while processing another one. In more concrete terms: I am preparing slides for a course. The slides include some developed examples (in particular, proofs) which I would like to make available as a separate handout. What I would like is to save these proofs, which I can enclose in a command, in a separate file to generate a separate paper. I could write these proofs in separate files and include them in the beamer presentation and in a handouts file, but I would prefer to avoid it, since it means maintaining several files and jumping from one to another one.
I guess it can be done based on
\typeout commands, but, is there any other higher-level, partially cooked solution already available?
Thanks in advance!