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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to LaTeX and I'm trying to figure out how to correctly format a proof. Can someone show me a basic template for how to do this?

The part I am having the most trouble with is creating new columns and customizing alignment... for instance, how do I add a right-aligned annotation (i.e. by distributive property) to a line of this sample proof? Should I use eqnarray* or is there a better option?

  Let $t,u \in \mathbb{R}$ where $t=xy$ and $u=zw$. So,
    4xyzw &=& 2\cdot2tu \\
    &\le& 2\cdot(t^2+u^2) \\
    &=& 2\cdot((xy)^2+(zw)^2) \\
    &=& 2\cdot(x^2y^2+z^2w^2) \\
    &=& 2x^2y^2+2z^2w^2 \\
    &\le& ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2) \\
    &=& x^4+y^4+z^4+w^4
share|improve this question
Consider \eqnarray vs align with regards to your last question of using eqnarray*. The short of it is that you should rather avoid it in lieu of something like the align environment from amsmath. – Werner Sep 2 '11 at 16:57
up vote 10 down vote accepted

Adding to egreg's remarks: to add right-aligned annotation — in parentheses — you can use the \tag macro; to have annotation without parentheses, use the \tag* macro. (This must be given before the line-break; for this reason, I like to put the line break immediately before the following line, but that's just my personal style.) And again, as egreg noted, you should use \qedhere on the last line of an equation environment, if your proof ends at an equation.

  &= 2\cdot2tu 
  \\ &\le 2\cdot(t^2+u^2)                    \tag{a remark in parentheses}
  \\ &= 2\cdot((xy)^2+(zw)^2)
  \\ &= 2\cdot(x^2y^2+z^2w^2)                \tag*{a remark without parentheses}
  \\ &= 2x^2y^2+2z^2w^2
  \\ &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2)
  \\ &= x^4+y^4+z^4+w^4                      \qedhere

If you find yourself having multi-line equations where you want equation numbers — but only on the last line — the macro \notag will also come in handy. (I insert them just before the line-breaks, to make it easy to copy the sequence \notag \\ &= for multi-line equations.)

  &= 2\cdot2tu 
  \notag\\ &\le 2\cdot(t^2+u^2)                    \tag{a remark in parentheses}
  \\ &= 2\cdot((xy)^2+(zw)^2)
  \notag\\ &= 2\cdot(x^2y^2+z^2w^2)                \tag*{a remark without parentheses}
  \\ &= 2x^2y^2+2z^2w^2
  \notag \\ &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2)
  \notag \\ &= x^4+y^4+z^4+w^4

Edited to add: don't use \tag or \tag* for remarks, unless you're happy with them appearing on the left (instead of on the right) whilst using the lefteqn option.

share|improve this answer
I wouldn't abuse \tag for annotations: with the lefteqn option they will go to the wrong side. Use rather align's features: a&=b &&\text{remark} – egreg Sep 2 '11 at 17:14
Hm. I didn't know that, perhaps as a result of not using lefteqn. I adopted this method (those rare times when I've used it) as it is a way of getting remarks flush with equation numbers. – Niel de Beaudrap Sep 2 '11 at 17:23
Easy: never ever use eqnarray – egreg Sep 2 '11 at 17:33
@alexjlockwood: typically, it means "advance to the next column". In eqnarray (don't use it!) equations are blocked into groups of three columns: right-aligned, center-aligned, and left-aligned, after which you jump rightwards some distance to start a new equation further to the right. In align, equations are blocked into groups of two columns: right-aligned, and left-aligned. You'll also encounter & any time you use a table, or a matrix, or similar sorts of environments. – Niel de Beaudrap Sep 2 '11 at 17:37
@alex: Jumping of Niel's comment, there is a somewhat more specialized environment called alignat that gives you complete control over how the equation breaks into columns. It's useful if you have several stacked equations which should be aligned at multiple points, with appropriate padding added to make that happen. I only mention it because this effect is impossible to obtain otherwise, but it will be a long time before you need to use it. You should read amsldoc.pdf (or the result of texdoc amsmath) to learn about how these things work. – Ryan Reich Sep 2 '11 at 18:01



  Let $t,u \in \mathbb{R}$ where $t=xy$ and $u=zw$. So,
    4xyzw &= 2\cdot2tu \\
    &\le 2\cdot(t^2+u^2) \\
    &= 2\cdot((xy)^2+(zw)^2) &&\text{(substituting variables)} \\
    &= 2\cdot(x^2y^2+z^2w^2) \\
    &= 2x^2y^2+2z^2w^2 \\
    &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2) \\
    &= x^4+y^4+z^4+w^4 &&\qedhere


The alignment is better (eqnarray should never be used for serious mathematical writing) and, moreover, the "end-of-proof" can be placed aligned with the last equation; \qedhere is necessary only when the proof ends with an alignment environment or with a list (enumerate, itemize or description); the && before \qedhere is only necessary when there are other comments.

I didn't check the math, though. ;-)

align with QED and comment

share|improve this answer
thanks for the info! should the QED symbol always be placed to the far right of the last line of text? is that convention? – Alex Lockwood Sep 2 '11 at 17:28
@alex: It has become convention because of how amsmath places the symbol :) The important point is that you should use \qedhere if the last line is inside an equation, since otherwise the QED ends up alone on the next line, which is ugly. – Ryan Reich Sep 2 '11 at 17:57
@alex, @Ryan -- the qed symbol (sometimes called the "tombstone") was placed to the far right by many math publishers long before amsmath came into being. that said, the position is considered to be a "house style". the originator appears to be Paul Halmos; see Handbook of Writing for the Mathematical Sciences, by Nicholas J. Higham, quote on p.11. before the square, "qed" in small caps was often used to indicate the end of a proof, and some authors still prefer that. – barbara beeton Sep 2 '11 at 19:15
"eqnarray should never be used for serious mathematical writing" - I've used it for 10 years now ... – Martin Brandenburg Mar 28 '15 at 1:50
@MartinBrandenburg You're always in time for switching to serious math writing. ;-) – egreg Mar 28 '15 at 10:16

This is not an elegant solution but might be an option nevertheless. You can also fake it with a tabular. This way, you can print some borders if you want (just in case of those provide-the-missing-part tests so loved by some high school math teachers).



\lvert p-q\rvert & =\sqrt{(p-1)^2} & \hphantom{some text} & by definition of square root\\
    &=\sqrt{p^2 -2pq +q^2} & &  by multiplication\\
    &=\sqrt{p^2-2pq+q^2 +2pq -2pq} & & by the additive identity\\
    &=\sqrt{p^2+2pq+q^2 -4pq} & &     by grouping like terms\\
    &=\sqrt{(p+q)^2 -4n} & &          by the distributive law\\

share|improve this answer

One may also use the alignat environment. See the following:

4xyzw &= 2\cdot2tu                              \justif{\quad}{remark}\\
    &\le 2\cdot(t^2+u^2)                        \justif{\quad}{remark}\\
    &= 2\cdot((xy)^2+(zw)^2)                    \justif{\quad}{remark}\\
    &= 2\cdot(x^2y^2+z^2w^2)                    \justif{\quad}{remark}\\
    &= 2x^2y^2+2z^2w^2                          \\ % no remark
    &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2)   \justif{\quad}{remark}\\
    &= x^4+y^4+z^4+w^4        

enter image description here

Note the introduction of a \justif{<horizontal space>}{<content>} command that takes as arguments the separation and content (remark).

share|improve this answer

Your Answer


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.