# How to define environments for questions and answers

I wish to do a simple question and answer sheet for my students. I'd like to have something like this:

\section{Differential Equations}

\begin{questions}

\begin{question}
... Question here ...
\end{question}

\end{questions}


I wish to have the environment QUESTIONS to have counters like enumerate. That is, each \begin{question} ... \end{question} should behave just like \item in

\begin{question}
\item
\end{question}


The \begin{question} ... \end{question} environment should take "normal" LaTeX commands.

If possible, I'd wish to have deferred printing to print the answers at the end of the document.

I first tried this

\makeatletter
\newcounter{question}
\setcounter{question}{0}
\def\thequestion{{\bfseries{Question \arabic{question}. }}\\}

\newcommand{\question}[1]{\stepcounter{question}\par\noindent\thequestion#1}
\makeatother


but it's not behaving the way I'd love the results to be ...

Simple use of exam package :

\documentclass{exam}
\begin{document}

\section{Differential Equations}
\begin{questions}
\question ... Question here ...

\begin{solution}[.2in]
\end{solution}

\question Long descriptive question about everything

\begin{solutionorlines}[2in]
\end{solutionorlines}

\question Draw an arrow showing north direction.

\begin{solutionorbox}[2in]
$\uparrow$
\end{solutionorbox}

\end{questions}

Stuff to appear only when answers \textbf{are} being printed.
\else
Stuff to appear only when answers \textbf{are not} being printed.
\fi

\end{document}


Commenting and uncommenting \printanswers yields in one of two following:

1)

2)

I don't see any lack of functionality compared to your example.

• At my department, we took exam.cls as a foundation for our own examination class, so that the cover page would always look the same, and it works very well. It is very flexible. – Benjamin McKay Oct 21 '13 at 15:20