Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I was wondering if there is a good general purpose homework class file/template out there. I want to use it for classes. Generally, math-centered courses. I would like if there was syntax highlighting for programming (Python, Ruby, C, Java, etc.).

share|improve this question
    
You might also want to look into the answers package, it is very nice =) –  N3buchadnezzar Mar 19 '12 at 23:09

3 Answers 3

up vote 10 down vote accepted

For the class file itself: I actually made my own class file (adapted from the report class file) to format my homework the way I wanted. It is here, if you're interested in trying it or fiddling with it:

https://gist.github.com/1278588

You supply it with \author and \title in the preamble, and it automatically uses today's date.

This file is used by inserting \documentclass{jhwhw} at the beginning of a document.

The standard formatting for a problem looks like this:

\problem{NAME OF PROBLEM}
  <<statements of problem>>
\solution
  <<solution>>

It creates a new page for every problem. Also, if a problem has multiple "parts" the formatting might look like this

\problem{NAME OF PROBLEM}
  \begin{enumerate}
    \item <<Part (a) problem statement>>
    \item <<Part (b) problem statement>>
  \end{enumerate}
\solution
  \part
    <<Solution to part (a)>>
  \part
    <<Solution to part (b)>>

The enumerate will use letters (a), (b), etc. And \part will use (a), then (b), etc.

An example page (from a real homework assignment) looks like this picture

If you want to try it out, download it, put it in your texmf folder and run texconfig rehash (if you're on a UNIX based system).

There are definitely things in this class file that are automated that people would want more control over, so I suggest fiddling around to find what works best for you.

For syntax highlighting: Werner's answer mentioning the listings package for syntax highlighting and code is great. (That style file could be used with this class file.)

share|improve this answer
    
Hey man is there a way to prevent each problem from starting on a new page? –  Antillar Maximus Sep 2 '13 at 22:03
1  
Yeah, in the \newcommand*{\anyproblem}[1]{\newpage\subsection*{#1}} line of the style file (as of this writing: L60), remove the \newpage. That should prevent it from starting each problem on a new page. –  thequark Sep 27 '13 at 20:38

In my opinion the (standard) article document class would work for that. The reason for not suggesting something like book or report is that they are meant for much larger texts (since they include chapters and parts). Additional syntax-highlight can be obtained by means of the listings package - you specify the language (and possibly other formatting) and put the code in a lstlisting environment and that's that. See the listings documentation for more information on this (p 12 presents a list of supported languages, although you can define your own).

For mathematical typesetting, I would suggest using the amsmath package as well. It provides the powerful align environment for typesetting equations (numbered; otherwise, for unnumbered equations using align*) with alignment properties. It also improves on other standard mathematical components used in LaTeX.

Here's an outline of what I'm talking about:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{listings}% http://ctan.org/pkg/listings
% ... other packages that you may want to use
\begin{document}
% Sectional headings...
% Paragraph text...
% Enumerate/itemize environments...
% Listings (or programming code segments)...
% Tables...
% Figures...
% Mathematics (align, align*, \[ \], ...)
\end{document}

If, in general, your expertise in LaTeX needs a solid foundation, consider reading through the Not So Short Introduction to LaTeX2ε.

share|improve this answer
    
Also consider the exam class (related question) for a question/answer structure. –  Mike Renfro Oct 11 '11 at 3:12

You can make a keyword search at CTAN and under exams you will find a complete list of packages realted with exercises or exams. I think most of them are compatible with listings and minted to typeset code.

share|improve this answer
    
The links have since rotted. Is there an alternative? –  Mike Sep 20 at 23:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.