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.

\documentclass{article}
% Set this =0 to hide, =1 to show
\def\showanswers{0}

\newcommand{\hide}[1]{
\ifnum\showanswers=1

#1 \vspace{\baselineskip}
\fi

\ifnum\showanswers=0

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

\begin{document}

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


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

\end{document}
//
Scroll to Top