A more structured way to typeset assignments in LaTeX

Solution 1:

I found this example. It's not exactly what you want, but if you look up using counters and the newcommand and renewcommand definitions, you should be able to do exactly what you want, which wasn't totally clear to me.

\documentclass{article}
\begin{document}

\newcounter{set}
\setcounter{set}{2}
\newcounter{problem}[set]

\newcommand{\problem}{\refstepcounter{problem}{\vspace{2\baselineskip}\noindent\large \bfseries Problem~\arabic{set}.\arabic{problem}}\\}

\problem
\textit{Sum-product algorithm:}  Consider the sum-product\ldots.

\problem
\textit{Max-marginals:} Consider the max-marginals\ldots.

\stepcounter{problem}
\problem
Demonstraction of \verb"\stepcounter"

\addtocounter{problem}{-1}
\problem
Counter increments can be negative!

\end{document}

Solution 2:

I use the exam document class for this task. A basic document then looks like this:

\documentclass[answers]{exam}
\begin{document}
\firstpageheader{}{}{\bf\large Name \\ Class \\ Assignment \\ Due Date}
\runningheader{Name}{Class Assignment}{Due Date}

\begin{questions}
\question
    This is the question.

\begin{solution}
    This is the solution to the question.
\end{solution}

\end{questions}
\end{document}

Prior to discovering the exam class, I used the hmcpset document class from the mathematics department at Harvey Mudd College.