For the class file itself: I actually made my own class file (adapted from the class file) to format my homework the way I wanted. It is here, if you're interested in trying it or fiddling with it:
You supply it with and in the preamble, and it automatically uses today's date.
This file is used by inserting at the beginning of a document.
The standard formatting for a problem looks like this:
It creates a new page for every problem. Also, if a problem has multiple "parts" the formatting might look like this
The will use letters (a), (b), etc. And will use (a), then (b), etc.
An example page (from a real homework assignment) looks like this
If you want to try it out, download it, put it in your folder and run (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 package for syntax highlighting and code is great. (That style file could be used with this class file.)
12 February 2014
Doing Your Homework in LaTeX
It is a common occurrence for other students to comment on my homework whenever I turn it in for one of my classes.
The complete LaTeX file (and the pdf output) can be found in my repository, latex-homework-template.
View on GitHub
Below are a few screenshots of problems that Iâve done in the past:
If I didnât know how easy it was and the benefits that I get from typesetting my homework, Iâd probably ask as well. However, Iâd argue that using LaTeX to type up homework has made me a far better student than when I used to handwrite my homeworks.
And that is something that I care a lot about.
I can summarize the benefits like so:
It can be kept in Source Control. Handwriting canât be stored in a version control system; once you erase something, itâs gone.
You can see your homework materialize in front of you. Seeing the results and the equations in their complete LaTeX-glory is a very powerful way to conceptualize things. Thereâs just something different about the way things look so perfect that makes the subject easier to understand.
Youâll do better in your classes. This one goes with the previous point, but having the ability to see your homework helps you understand it. By understanding it well, youâll do better on tests. You will maximize how much you can learn as well as maximize your grade (if that matters to you).
Itâs very neat & tidy. Although my handwriting has improved quite a bit, I still find myself slipping back into a rushed, messy script from the past. LaTeX gives zero doubt that the professor/TA will be able to read my solutions.
A Very Short History
Donald Knuth, a legendary Computer Scientist as well as one of my favorites, is well known for the system that he created called just TeX.
It is a piece of typesetting software that aids in writing documents and formulas. The power comes from the fact that the document that you write is plain source code.
The code that you write is then âtypesetâ into the final document in whatever form you wish.
Hereâs an example of some basic LaTeX code:
With the output looking like below:
Using the Template
Iâve created a GitHub repository, latex-homework-template, just for my homework template that Iâve been using ever since I started. I found it online and used it as a base to start my template.
To use it, just download the homework.tex file and start editing. Once you need to typeset it, youâll need LaTeX here.
After that, you just need to compile it and youâll get your output. There are tons of different resources that Iâve found useful in learning LaTeX:
Affect on Performance
I have a solid set of anecdotal evidence in favor of using LaTeX for writing up my homework.
In all the classes that Iâve used LaTeX, Iâve come out of the class with a very strong understanding of the material as well as a good grade. Although Iâm not a big fan of grades (like at all), I know it matters to some people.
This might have to do with the fact that doing the homework in LaTeX takes longer. It might have to do with the fact that I perfect the appearance and spend a lot more time looking at the subject.
The most likely reason is a combination of all that I previously mentioned plus other factors. Iâm usually one to always want to quantify something, but in this case, I know it helps; thatâs all I need.
There definitely is a learning curve when it comes to trying to use LaTeX for homework. I felt that it was definitely worth the effort unlike how it might seem to some students.
I reasoned that when I go to graduate school, I will want to use it there. I also know how pervasive it is in textbooks. Since I love to read textbooks so much, I wanted to see what it took to write them so elegantly. I may even want to write one in the future; weâll have to see =]
To me it seemed like a small tradeoff for the great benefits that it provided.
I cannot recommend using LaTeX for your homework enough.
The benefits go a long way. It helps you learn the material and in a way that isnât as easily achieved when just using pencil and paper.
LaTeX is also widely used in academia and learning about the tool is almost essential if you wish to go to graduate school.
Once I graduate from university, I plan on releasing all my code for the last three semesters as open source. It includes all my LaTeX code which has really accumulated over the last year. It should provide a nice resource for others.
In the meantime, hopefully if you start using LaTeX for your homework, you wonât be able to resist doing it early because of how fun it is. Well, at least it was fun for me =]
You're awesome for reading this. You should follow me on Twitter and GitHub.