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 .

Below are a few screenshots of problems that I’ve done in the past:

Cover page

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.

The Benefits

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.

About LaTeX

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:

Example output

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:

TeX StackExchange

LaTeX Wikibook

Effect 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.

Learning Curve

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 =]

02 Using LaTeX for Homework

I hope that you will use the LaTeX typesetting system to write your homework solutions for this course. (See the guide to submitting homework.) It might look daunting at first, if you haven't used LaTeX before, but you won't have to learn LaTeX in depth. You just have to fill in answers to exercises, so you won't need to deal with the complexities of writing complete documents. You will mainly need to know how to express mathematics in LaTeX. Unfortunately, matrices and systems of linear equations are among the more difficult things to write. Fortunately, you will have examples that you can imitate. What follows here is some basic information to get you oriented.

Using LaTeX is something like programming: You write "source code" in plain text, which is "compiled" to produce the actual document. Perhaps the first thing to know is that to start a new paragraph, you need to leave a blank line. Other than that, carriage returns are ignored. Also, multiple consecutive spaces are treated as a single space.

To Include mathematics in a document, you type the LaTeX source code for the math between dollar signs. For example, $ax^2+bx+c=0$ will be typeset as \(ax^2+bx+c=0\). If you enclose the code between double dollar signs, the math will be displayed on on line by itself. (This is called "displayed math.") For example, $ $ax^2+bx+c=0$ $ will be typeset as \[ax^2+bx+c=0\] Some things look different as displayed math. For example, compare \(\lim_{n\to\infty}\sum_{k=1}^n\frac{1}{2^n}=1\) to \[\lim_{n\to\infty}\sum_{k=1}^n\frac{1}{2^n}=1\] If case you are wondering, the LaTeX code for that is \lim_{n\to\infty}\sum_{k=1}^n\frac{1}{2^n}=1 . Remember that it has to be enclosed between either single or double dollar signs. Stuff that is between dollar signs is said to be in math mode , as opposed to the regular "text mode."

In the source code, certain characters have special meaning: $ \ { } ^ _ & ~ # % . We have seen that $ is used to surround math code.

The backslash character, \ , is used for LaTeX commands, and braces, { and } , are used to enclose the parameters to which a command applies. For example, in \sqrt{b^2-4ac} , the command is \sqrt , the parameter is b^2-4ac , and the typeset result is \(\sqrt{b^2-4ac}\). The \frac command is used to make a fraction, and it has two parameters, so \frac{n!}{k!(n-k)!} is typeset as \(\frac{n!}{k!(n-k)!}\). Some commands don't have parameters. For example, \infty represents the infinity symbol, \(\infty\), and \to produces a right arrow, \(\to\). Note that you might need to leave a space after a command like \to to mark the end of the command word. For example, use f\colon X\to Y to get \(f\colon X\to Y\). Typing \colonX instead of \colon X will just get you an error.

The special characters caret, ^ , and underscore,  _ , are used for exponents and subscripts in math mode. Note that if an exponent or subscript is more than one character or command, it must be enclosed in braces, so you need f^{-1}(x_i) to get \(f^{-1}(x_i)\). Some similar things, such as the upper and lower limits on a sum ( \sum_{n=1}^\infty for \(\sum_{n-1}^\infty\)) and the thing that goes below "lim" ( \lim_{x\to a} for \(\lim_{x\to a}\)). By the way, in display math, that would look like \(\displaystyle\lim_{x\to a}\). If you want to force some math into display style, use the command \displaystyle in regular math mode: $\displaystyle\lim_{x\to a}$ .

We will see that the amphersand, & , is used similarly to a tab character in tables and matrices. The other three special characters probably won't come up in your writing for this course. (A  ~ represents a non-breaking space, #  is used when defining new commands, and %  marks the start of a comment that ends at the end of the same line. Comments are ignored by LaTeX.) Most of the special characters can be output to the typeset document by preceding the character by a backslash in the source code. For example, type  \{ for \(\{\). However, this does not work for the backslash character; \\ is used to force a line break in the output. It also does not work for \^  or  \~ (which are used for making accented characters). I also note that | , < , and  > work in math mode but give funny results if used outside of math mode.

Some LeTeX code uses environments . Environments are coded using \begin and \end , which take the name of the environment as parameter. For example, you will write your solution to exercises in this course using my " answer " environment. That means that you will write your solution between \begin{answer} and \end{answer} . Similarly, I will write the problem text between \begin{problem} and \end{\problem} . (These two environments are not built into LaTeX. It is possible to define new environments and new commands in a document. The LaTeX source files that I give you will already define any extra commands and environments that you need.)

If you are going to use LaTeX in this course, you need to learn about matrix environments. To produce a matrix enclosed in parentheses, use the pmatrix environment. The rows of the matrix are separated by \\ . In each row, the elements of that row are separated by  & . All of that goes between \begin{pmatrix} and \end{pmatrix} , and it must all be in math mode or displayed math mode. LaTeX ignores end-of-lines in math mode, but it's a good idea to lay out the matrix in the source code similarly to how it looks when typeset (except I don't always do that for simple column vectors, which have just one element per row). For example,

will produce this in the typeset document: \[\begin{pmatrix} 3 & -10 & 2 \\ -1 & 7 & 4 \\ 5 & 0 & 1 \end{pmatrix} \begin{pmatrix} x\\ y\\ z \end{pmatrix} = \begin{pmatrix} 3x-10y+2z \\ -x+7y+4z \\ 5x+z \end{pmatrix}\]

Later, we will use the vmatrix environment to make matrices that are enclosed between vertical bars instead of between parentheses. There is a plain matrix environment for typesetting the elements of the matrix with nothing enclosing them. I use the matrix environment to typeset systems of linear equations, where each equation is one row in the matrix. Each term in an equation is one element of the row. The equal sign and the right-hand side of the equation are also elements. A column can be left empty—two & 's in a row—if a term is missing from the equation. For example:

gives \[ \begin{matrix} 3x_1 & -2x_2 & +x_3 & -x_4 & = & 7\\ -x_1 & & -5x_3 & +2x_4 & = & 2\\ & x_2 & +2x_3 & & = & 0\\ 2x_1 & +3x_2 & & -5x_4 & = & -1 \end{matrix} \]

Unfortunately, there is no simple environment for making augmented matrices. I use a pattern based on the array environment, which makes it possible to put lines between columns of the array and to say whether you want the columns to be centered, left justified, or right justified. This is specified in an extra parameter that comes after \begin{array} . For example, \begin{array}{cccc|c} is used for an array with five centered columns and a line between the fourth and fifth columns; you can use r and l instead of c to get right-justified or left-justified columns. Since the array environment does not include parentheses, I have to add them myself: \left( and \right) add appropriately sized parentheses around whatever is put between them. Here's the augmented matrix that represents the above linear system:

giving \[\left( \begin{array}{cccc|c} 3 & -2 & 1 & -1 & 7\\ -1 & 0 & -5 & 2 & 2\\ 0 & 1 & 2 & 0 & 0\\ -2 & 3 & 0 & -5 & -1 \end{array} \right) \]

The only other environment that is really essential is align* . This environment is unusual in that it is used for mathematics, but it has to be used in regular text mode, not inside math mode. Its purpose is to vertically align a sequence of rows. Rows are separated by \\ , and the position in each row that is to be aligned is marked with a  & . Often, a row is an equation or inequality (or just the operator and the right half of an equation/inequality), with the operators vertically aligned. Here is an example:

which is typeset as

\(\begin{align*} \frac{d}{dx}(x\sin(x^2)) &= x\frac{d}{dx}(\sin(x^2)) + \sin(x^2)\frac{d}{dx}(x) \\ &= x\cos(x^2)\frac{d}{dx}(x^2) + \sin(x^2)\\ &= x\cos(x^2)2x + \sin(x^2)\\ &= 2x^2\cos(x^2) + \sin(x^2) \end{align*}\)

For showing a series of row reductions applied to a matrix or linear system, you might use array or matrix environments inside an align* environment. This can get complicated, but an example is given in the first homework assignment. I have defined the command \rowop for making the arrows that go between the steps of a row reduction. The parameter to \rowop is either a single row operation or several operations separated by  \\ . For example, \rowop{\rho_2\leftrightarrow\rho_3} and \rowop{2\rho_1+\rho_2\\-3\rho_1+\rho_3} for \(\rowop{\rho_2\leftrightarrow\rho_3}\) and \(\rowop{2\rho_1+\rho_2\\-3\rho_1+\rho_3}\)

You can find lists of other LaTeX command elsewhere, and you will find examples in the documents that I give you. Here are a few more that you might use in this course. Most of these are used only in math mode, and a few of them require some preliminary configuration in the LaTeX file.

(back to contents)

Robert J. Won

Department of Mathematics, The George Washington University

How to TeX your homework

The TeX template used in the video is included at the bottom of this post. You can paste this into a .tex file locally, or into Overleaf.

  • If you’re just starting out, I recommend using  Overleaf  as your TeX editor.
  • You can use  Detexify  to hand-draw a symbol to find the LaTeX command for it.
  • There is also a nice  WikiBook  on LaTeXing mathematics.
  • When in doubt, Google is your friend!

You will frequently have problems with TeX which will make the document unable to compile. You should remember to compile often so that you can pinpoint your errors. Here are some things to check.

  • Remember to place math within dollar signs, so $x^2$ typesets as  x 2 .
  • Make sure you have started and ended all environments in the appropriate spots.
  • Make sure you have closed all of your curly braces { }.
  • Check to see if you used a new command that requires a new package.

Leave a Reply Cancel reply

Save my name, email, and website in this browser for the next time I comment.

This site uses cookies to offer you a better browsing experience. Visit GW’s Website Privacy Notice to learn more about how GW uses cookies.

Typeset your math homework

  • Aug 24, 2019

Typing your math homework has two main advantages over hand written work. First, typeset mathematics is easier to read, for which your professor will thank you. Second, it is easier to edit, correct, and even write mathematics the first time when you are typing, since you can insert or delete content as you go.

How to typeset mathematics

The main challenge is that you need to figure out how to type all those symbols! Although word processing programs like Word or Google Docs allow you to insert “equations”, if you want to do any amount of serious mathematics, you will want to use a markup language . You type your document in plain text using the syntax (markup) of the language, and then compile your text document into a nicely formatted pdf or webpage.

Here we will consider two such languages; markdown and LaTeX. Here is the short version: Markdown is easier to get started with, but gives you less control over the structure and format of your document. LaTeX has a steeper learning curve but is the gold standard for writing math or science papers, and you will need to learn the LaTeX commands for math symbols to put them in Markdown anyway.

To get started right away, you can try online editors. For Markdown, I recommend StackEdit . For LaTeX, there is Overleaf . Both have good instructions on how to get started.

Not sure which to use? Let’s look at the features of each a little closer.

This document you are reading has been written in markdown. It is a very basic syntax for plain text documents that allows you to specify basic formatting easily. For example, to get title headings, you write something like # Main Title , or ## SubHeading . You can get italic text using *italic words* . Lists are easy as well. See this link or many other guides for an overview of what you can do.

So you write your document in a basic text editor, and then compile it into your output format, which could be HTML (for the web) or a pdf. This can be done on your computer, or using a online tool. Checkout StackEdit or markdown notes . Both tools are free and have nice interfaces. To get a pdf (to print or submit electronically), you can print the output and select “save as pdf”.

Both the editors above allow you to typeset math by calling LaTeX commands, although the format is slightly different (using $ or $$ to start or stop the “math mode”). Note that this is really an add-on to markdown, so other editors you find might or might not have the feature.

If you use one of the online editors, you can download the “source” files (it will have a .md file extension). One reason to do this is to use the program Pandoc to convert your markdown to other formats, including…

Like Markdown, LaTeX is a markup language. So you type your document in a text editor, and then compile it into a pdf (or other format, but mostly pdf). It used to be that this required that you install LaTeX packages on your computer (which isn’t hard, but is a big install). Now you can use an online editor called Overleaf . There you can type your documents and compile inside your browser (and then download the pdf). It also has a bunch of templates you can use (including homework templates) to get started.

That overleaf has templates is good, because there is a lot of baggage in a LaTeX document that tells it how to format everything. When you are starting out, you don’t need to worry about this (thanks to the templates). And all of this is really nice if you want to do anything beyond simple documents. For example, you can create numbered theorems (LaTeX keeps track of your numbers) and get nice proof…qed formatting around your proofs. You can also define macros, so that instead of typing \mathbb{N} to get \(\mathbb{N}\), you can write \N each time.

Using Pandoc, you can convert other formats, including Markdown and Word, to LaTeX. You could upload this to Overleaf, or compile yourself.

If you want to set up your computer to compile LaTeX documents, you can do this using MacTeX (for Mac OS) or MiKTeX (for Windows). Other options can be found here .

If you are a little adventurous, or plan to write scientific/mathematical papers in the future, it is worth figuring out LaTeX ASAP! There are some good tutorials online (for example this site looks to have lots of good resources).

Useful tools

  • MathPix Snip . Not sure how to write a math symbol in LaTeX? MathPix let’s you take a screen capture or photo with your smartphone of math and will translate it into LaTeX.
  • Detexify . You can draw a symbol with your mouse (or on your smartphone) and get suggestions of the LaTeX code to create that symbol.
  • Modern Text Editors. If you want to write markdown or LaTeX on your own computer, you should learn how to use a real text editor. I like VS Code , and used to use atom , both of which are free. Another option sis Sublime Text . All of these have extensions/plugins for markdown and LaTeX that can help you speed up writing.

Other options

Jupyter notebooks.

A jupyter notebook is a document that contains both executable code and regular text, which can be written in markdown. To run a jupyter notebook, you can install Anaconda or SageMath (depending on whether you want to execute Python code or Sage code). There are also some online jupyter notebook servers. CoCalc is a very good one, but the free version has performance issues.

Word or Google Docs

Both of these word processing programs allow you to insert math equations using an equation editor. However, if you plan to insert a lot of math, this can be slow. To speed it up a bit, learn the keyboard shortcuts. On Windows, the MS Word equation editor can be brought up using alt+= . The Google Docs equation editor requires alt+i, alt+e . The equation editor in Word is pretty good about taking LaTeX math commands and turning them into the correct symbols. There are nice collections of shortcuts available. Google Docs only works sometimes.

Doing the Right Thing

Whatever format you choose, you should use it correctly. In particular:

  • All math should be written in “math mode”. If you have a variable \(x\), you should put that inside dollar signs or use the equation editor. Do NOT leave it as just x, or even just make it italic. Do you see the difference: x vs \(x\). Which looks more like math? What about f(x) vs \(f(x)\)?
  • Other formatting should have semantic meaning, not just look pretty. This means that when you want to put a title in your document, you should format it as a title, not format it as larger font and bold. If you use Word, select Heading or Subheading. If you use LaTeX, type \section{your title} . In Markdown, use ## your title . This way, if you ever want to convert your document to another format, you have some hope of it working.

Homework Template with Samples

Homework Template with Samples

Get in touch

Have you checked our knowledge base ?

Message sent! Our team will review it and reply by email.

Email: 

COMMENTS

  1. Writing Math Homework in LaTeX

    Need easily formatted and good looking math homework? In this video I demonstrate how I write my homework in LaTeX.LaTeX is a text setting language which all...

  2. Doing Your Homework in LaTeX

    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: Cover page ...

  3. Using LaTeX for Math

    We have seen that $ is used to surround math code. The backslash character, \, is used for LaTeX commands, and braces, { and } , are used to enclose the parameters to which a command applies. For example, in \sqrt{b^2-4ac}, the command is \sqrt , the parameter is b^2-4ac, and the typeset result is b 2 − 4 a c.

  4. How to TeX your homework

    The TeX template used in the video is included at the bottom of this post. You can paste this into a .tex file locally, or into Overleaf. If you're just starting out, I recommend using Overleaf as your TeX editor. You can use Detexify to hand-draw a symbol to find the LaTeX command for it. There is also a nice WikiBook on LaTeXing mathematics.

  5. Simple Math Homework Template

    LaTeX Project Public License 1.3c. Abstract. I had to relearn LaTeX to turn in my real analysis homework last night, so I made it into a template in case others are in the same situation. Tags. Homework Assignment Math.

  6. Should I keep using LaTeX to do my math homework?

    4. My probability professor suggested us to try to use LaTeX for the homework. I have successfully wrote my first LaTeX project (5 pages). However, no one except me used LaTeX in that course. I spent 1 hour to do the homework on paper but 5 hours to convert it into LaTeX document (to debug, check math symbols).

  7. Typeset your math homework

    tech. tex. teaching. Aug 24, 2019. Typing your math homework has two main advantages over hand written work. First, typeset mathematics is easier to read, for which your professor will thank you. Second, it is easier to edit, correct, and even write mathematics the first time when you are typing, since you can insert or delete content as you go.

  8. teaching

    Only once I've tried to typeset math homework using LaTeX and it was a pain. It was much quicker to write up the answers on paper than to do context switching between typing up LaTeX, thinking & waiting/viewing the results. One way would be to have an interactive web2.0 website to submit LaTeX typeset answer with automatic rendering.

  9. Class file for Homework/Assignments

    This file is used by inserting \documentclass{jhwhw} at the beginning of a document. The standard formatting for a problem looks like this: <<statements of problem>>. <<solution>>. It creates a new page for every problem. Also, if a problem has multiple "parts" the formatting might look like this. \begin{enumerate}

  10. How to write your homework using LaTeX

    Get the (free) Homework Template https://www.overleaf.com/read/pycnqvvptsvf#94a8a3. This template is on Overleaf, my thanks to Overleaf for sponsoring toda...

  11. How to LaTeX (with math homework template)

    You can find the template at https://blogs.gwu.edu/robertwon/2021/07/18/how-to-tex-your-homework/

  12. Mathematical expressions

    This article shows the most basic commands needed to get started with writing maths using LaTeX. Writing basic equations in LaTeX is straightforward, for example: proved to be invalid for other exponents. \[ x^n + y^n = z^n \] \end{ document } Open this example in Overleaf. As you see, the way the equations are displayed depends on the ...

  13. LaTeX Resources

    as a starting point for your homework assignments typed in LaTeX. Hint: Look at this example and its LaTeX source code. Various reference sources . LaTeX reference sheet by Dave Richeson (2 pages) Math 290 LaTeX reference sheet (2 pages) LaTeX reference sheet by Winston Change (2 pages) Darrin Doud's Short Introduction to LaTeX

  14. Example of math homework exercises

    Last Updated. 5 years ago. License. Other (as stated in the work) Abstract. Sample LaTeX document of math homework, created by Robert Hanson. Source: Robert Hanson webpage. This template was originally published on ShareLaTeX and subsequently moved to Overleaf in October 2019. Tags.

  15. Example math homework (with solutions)

    An online LaTeX editor that's easy to use. No installation, real-time collaboration, version control, hundreds of LaTeX templates, and more.

  16. Doing My Homework in LaTex

    Last week I mentioned that I wanted to start doing my homework in LaTex. Today I talk about how it's going with respect to my classical mechanics homework.

  17. At what point should a math student be using LaTeX? : r/math

    Using LaTex to do homework is neat, but completly unnecessary. At no point should a class force the students to use LaTex. There is no such thing as too early. There's also no such thing as too late for in-person classes, provided the work is legible.

  18. Do you think students doing homework in LaTeX makes it harder ...

    I'm going to take your question very literally, and interpret the word "doing" to mean they are actually using latex to get their thoughts down right from the start, as opposed to doing the homework on paper and then transcribing it to LaTeX. Given that assumption, there are two cases to consider. It's really a matter of fluency and cognitive load.

  19. formatting

    3. I've been using this homework template I found online that is pretty light. I am very new to using LaTeX, and although I find writing basic mathematical expressions easy, some of the cooler more complex LaTeX stuff seems way above me. The homework template I found has this in it: \newcounter{prob} \newenvironment{problem}[1]

  20. Homework Template with Samples

    7 months ago. License. Creative Commons CC BY 4.0. Abstract. This is a template for completing homework assignments. It includes examples of how to use the template and how to type up various types of assignments. Tags. Homework Assignment University. Find More Templates.

  21. Math students: do you do your problem sets in Latex? Why or ...

    Never did. Good ol pencil and paper for me. I learned latex and used it for a couple of big projects, but there was just too much homework to do to do it in latex. I was always focused more on the math than the presentation. I remember there was just this one girl that did everything in latex.

  22. How do I create a simple page of homework in LaTeX?

    5. Here's one possibility: The first page of the resulting document: I defined some commands \idnumber and \classname for the ID number and the class name; the \makeheader command typesets the information for these two commands and \author, \title with the desired formatting.

  23. secondary education

    No, LaTeX should not be taught at high school. It is a skill that is costly to learn with essentially no benefit at high school level. Even at college level, it is not particularly useful. Homeworks are typically submitted handwritten which works perfectly fine. And for note taking LaTeX is far too slow.