LaTeX problem sets with hidden answers

LaTeX problem sets with hidden answers

I like being able to hide content in documents, for example including but not revealing the answers in a problem set. That makes it very easy to then produce the problem set solutions, simply by revealing the answers. I made this easier with a \hide{} command, that can be “turned off” so the answers are revealed.

This is the basic code I use for producing problem sets. The only change needed to convert a problem set into a solution set is to redefine the \showanswers variable to equal 1 rather than 0.


% Set this =0 to hide, =1 to show


   #1 \vspace{\baselineskip}

   \vspace{2\baselineskip} \hspace{2cm}


   \item This is question 1.
   \hide{Here is a hidden solution.}

   \item What is the answer to question 2?
   \hide{The answer is here.}


Leave a Reply

Your email address will not be published. Required fields are marked *