I want to typeset Mathematical problem-sets in Latex. My requirements are as follows:
When I type them in, I want the questions and the answers to be next to each other in the source-code so that fixing errors, etc. can be done easily.
However, when the document is typeset, I want the answers to appear in a separate "Answers" section just the way they do in textbooks.
Does anyone know of a way to do this?
Many thanks in advance!
You are looking for deferred printing. There are packages that can handle this problem, for instance exercise
. This does exactly what you're looking for.
Define a 'question' and a 'solution' environment in your questions.tex
file (say). Include questions.tex
twice. The first time, include questions only. The second time, include solutions only.
\usepackage{version}
% Include questions but not solutions:
\includeversion{question}\excludeversion{solution}
% Include solutions but not questions:
%\excludeversion{question}\includeversion{solution}
\begin{document}
\begin{enumerate}
\item % Shared question marker.
\begin{question}
Question goes here.
\end{question}
\begin{solution}
solution goes here
\end{solution}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With