# Any way to separate final Answer and Solution?

I am using exam package to typeset few problems along with its solutions.

\question Evaluate $\int \frac{x^{4}}{x^{2}+1} d x$
\begin{solution}
Solution: $\int \frac{\mathrm{x}^{4}}{\mathrm{x}^{2}+1} \mathrm{~d} \mathrm{x}=\int \frac{\mathrm{x}^{4}-1+1}{\mathrm{x}^{2}+1} \mathrm{~d} \mathrm{x}$
\begin{aligned} &=\int \frac{x^{4}-1}{x^{2}+1}+\frac{1}{x^{2}+1} d x \\ &=\int\left(x^{2}-1\right) d x+\int \frac{1}{x^{2}+1} d x \\ &=\frac{x^{3}}{3}-x+\tan ^{-1} x+C \end{aligned}
\end{solution}


I want to separate "final answer" from the "solution".

So that I can give a handout containing:

1. just questions & final answers.
2. Or sometimes just the questions (without answers or solutions).
3. Or sometimes questions and solutions.

I am hoping for something like this:

\question question
\begin{solution}
solution
\end{solution}


Now, I should be able to print just final answers using \printanswers (or some command like that) and printing of solutions controlled by \printsolutions.

I don't have any preference for exampackage, I am using it because it has \printanswers and nice solution environment. I am open to use any other package.

EDIT: Adding some custom code to any latex packages/classes is also okay. I just need this thing to work. It would be ideal if there is a facility to deferred print the options.

• Take a look at the xsim package Sep 25 at 10:46
• @HafidBoukhoulda: I am a latex newbie, I have gone through the documentation. I found it bit difficult to comprehend. Can you please show me how its done using that package? Sep 25 at 10:57
• What is the difference between answer and solution? Can you edit your question to provide an example ? Sep 25 at 11:36
• @HafidBoukhoulda: Answer = final answer of the problem. Solution = the entire mathematical process involved in reaching the final answer. Sep 27 at 5:03
• @HafidBoukhoulda I have added a picture for clarificiation, I hope my intent is clear now. Sep 27 at 5:05

\usepackage{environ}


Then you use

\begin{shortanswer}
42

to add answers and \printshortanswers to print the answers.
You can change how the answers are displayed by changing the line marked with % Customize here