# Creating separated tex files using the versions package

I have a midterm exam written with the solutions included using the versions package. I use this to create an assignment/exam PDF and a solution PDF from the same basic tex file (this is great---change a question a bit and you don't have to change the question in a separate solutions file).

Is there a way to create separate assignment and solution tex (as opposed to PDF) files that exclude and include the appropriate version environments? The reason that I want to do this is because this is a take-home exam and some students want to submit their answers using LaTeX on the original file.

-
It's not necessary to begin your questions with a greeting. – lockstep Mar 15 '11 at 19:19

## 1 Answer

You are probably looking for a pure TeX/LaTeX solution but I'd try to solve the problem on a different level: I'd use a Makefile and the Unix sed command to derive a LaTeX file that does not contain the solutions any more. If each solution is included in some environment, something along the following lines would do it:

sed '/\\begin{solution}/,/\\end{solution}/d' file.tex > file-without-solutions.tex


Both file.tex and file-without-solutions.tex could be compiled to PDF files with the additional benefit that you could hand out the source code for file-without-solutions.tex.

-
Makefile works for me---thanks! – Charlie Mar 16 '11 at 4:40