I am writing an exam for a course I am teaching. I want to be able to easily compile a version of the document with solutions and one without solutions. Below a minimal working example:
\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
\item{[1 point] Two plus two is equal to what?}
\begin{footnotesize}
\begin{itemize}
\item $2+2 = 4$
\end{itemize}
\end{footnotesize}
\item{[1 point] How many months are there in a year?}
\begin{footnotesize}
\begin{itemize}
\item There are 12 months in the year
\end{itemize}
\end{footnotesize}
\end{enumerate}
\end{document}
What I want is a way of automatically commenting out the solution lines. Such as an if statement. If solution = true, then print the solution of the exam. Else do not print.
\solution{<whatever>}
in the document you can switch between some like\def\solution{#1}
and\def\solution{}
in the preamble, so you need only type/remove#1
, or have both definitions and just inactivate one with a%
before.