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

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.