\documentclass[12pt]{article}
%% Contributed by Asher Kach (kach@math.wisc.edu)
%% Attached is a LaTeX file (quiz.tex) which allows you to keep an assessment
%% (i.e. a quiz) and its solutions in a single LaTeX file.  By toggling the
%% value of the boolean "answer", you specify whether or not you want the
%% solutions printed.
%% 
%% It works by printing the solutions to the problems in white if "answer" is
%% toggled off (i.e. for the quiz) and in black if "answer" is toggled on
%% (i.e. for the solutions).  Since it 'prints' the answers in white for the
%% quiz version, empty space is left for the students to do their work.
%% Note that if you use the <latex> command, xDVI displays the white text in
%% black (although it should print correctly).  If you use the <pdflatex>
%% command, acroread displays and prints the white text correctly.
%% 
%% The LaTeX file contains some comments that explains how it works, but not
%% that many.  If you have any questions, comments, or suggestions, let Asher
%% know.
%% 

% Commands to format the margins
\setlength{\topmargin}{-.75in}
\addtolength{\textheight}{2.00in}
\setlength{\oddsidemargin}{.00in}
\addtolength{\textwidth}{.75in}

% Command to include various LaTeX packages
\usepackage{amsmath,color,graphicx}

% Command to prevent auxiliary files from being created when compiling
\nofiles

% Command to prevent the pages from being numbered
\pagestyle{empty}

% Command to set the paragraph indentation to zero (i.e. none)
\setlength{\parindent}{0in}

% Commands that allow both quiz and solution versions to be created
\newif \ifanswer
\newcommand{\question}[1]{\ifanswer {\em #1} \else {#1} \fi}
\newcommand{\questiononly}[1]{\ifanswer \else #1 \fi}
\newcommand{\answer}[1]
        {\ifanswer \else \color{white} \fi #1 \color{black}}
\newcommand{\answeronly}[1]{\ifanswer #1 \fi}

% * * * * * * * * * * * * * * * * * * * * * * *
% Commands to set whether the quiz or solution is being created
%	If you want to create the quiz, comment out the first line but not 
%	the second.
%	If you want to create the solutions, comment out the second line
%	but not the first.
% * * * * * * * * * * * * * * * * * * * * * * *

% \answertrue 
\answerfalse

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% A header line

\noindent {\sc Math XXX
			\hfill Quiz ZZZ
			\hfill ZZZ September 2006}

\bigskip

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{\bf Problem 1 (4 points):} \question{ 
Solve the equation $$2x + 1 = 7.$$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bigskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\answer{{\bf Solution:} 
Subtracting one from both sides yields
$$2x  = 6.$$
Dividing both sides by two yields
$$x = 3.$$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vfill
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Additional white space can be generated by uncommenting the following
% line and adjusting the amount appropriately.
% \vspace{1.25 in}

{\bf Problem 2 (3 points):} \question{ 
Perform the requested integration in the indefinite integral 
$\displaystyle \int \sin 3x \, dx$.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bigskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\answer{{\bf Solution:} 
Making the $u$-substitution $u = 3x$, we have $du = 3 \, dx$, so that $dx 
= 1/3 \, du$.  Hence
\begin{eqnarray*}
	\int \sin 3x \, dx
		&=& \frac{1}{3} \int \sin u \, du \\
		&=& - \frac{1}{3} \cos u + C \\
		&=& - \frac{1}{3} \cos 3x + C.
\end{eqnarray*}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vfill
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
