I teach at the university and I write exams in Tex. I'd like to write an exam with a number of questions, where for each question I include either empty lines and empty figures with axes (for the actual exam - students to fill) OR the solution, including complete figures. For example:
Q. Illustrate what happens to the demand of housing when interest rates go down.
\begin{nosolution}
A FEW HORIZONTAL LINES
\begin{figure}
\includegraphics[scale=1]{EmptyGraph_withAxes}
\end{figure}
\end{nosolution}
\begin{solution}
It will increase....
\begin{figure}
\includegraphics[scale=1]{HousingDemand}
\end{figure}
\end{solution}
Then set a paramater at the beginning of the exam such as \printsolution, which says to print what is within the \begin{solution}...\end{solution}, and otherwise print what is within the \begin{nosolution} ... \end{nosolution}. I defined a solution and nosolution environment:
\newenvironment{solution}
{
\vspace{0.5cm}
\textbf{Solution.} \quad \itshape
}{}
\newenvironment{nosolution}
{
\hrulefill
\hrulefill
\hrulefill
}{}
Is there a way to switch between one and the other depending on an initial parameter like \printsolution? I have been trying the exam class (exam.cls) but it is not perfect for what I need to do because it cannot take floats in the solutions: I get a lost float message. I also checked the documentation which confirmed that floats are not supported because it uses frames. thanks, Mario
floats
a possible solution is not using them. I include graphics in my exams with just\includegraphics
(withoutfigure
) where I need them.floats
mean this, graphics will appear where LaTeX considers. They are good for documents, but I don't think the same for short exams.