I would like to write some tutorials for my students, and for this I am using the exam
document class, and the solution
environment.
now the problem is I have a statement
\printanswers
that I need to comment for the tutorial, and uncomment for the solution.
I was hoping if there's a way through which I can compile it a single time, and the source file (say tutorial.tex) creates two pdfs –
- tutorial.pdf (without solutions)
- tutorialSolution.pdf (with solutions)
Following is my source code –
\documentclass{exam}
%\printanswers
\usepackage[T1]{fontenc}
\usepackage{pslatex}
\usepackage[pdftex]{color}
\usepackage[pdftex]{graphicx}
\begin{document}
\begin{questions}
\vskip 0.5 cm \question Question header \vskip 0.5cm
Question text
\begin{solution}
Solution text
\end{solution}
\end{questions}
\end{document}
thanks for any help you can provide.
gaurav
Best Answer
Here is what I had in mind for one method you might use to manage this type of workflow.
You create 3 files. The first is your main file,
tutorial.tex
, say:The other two are wrappers. For example, these might be
tutorialQuestions.tex
:and
tutorialSolutions.tex
:You can then compile
tutorialSolutions.tex
andtutorialQuestions.tex
separately without overwriting the other version. Or you could use a script to manage this for you. (How to do that depends on your OS.) It is also possible to use various helpers with TeX to do a lot of this and/or have your IDE automate things. However, the above is the basic idea which you then embed in the way that best suits your preferred tools.