I often use $$...$$ to write mathematical formulae. I would like to know how to add a sequential number on the right hand of the formulae. I want them to be right adjusted at the right edge of the page. Also, it would be great if the numbers could be automatically generated.

Could anyone help? Thank you very much!

2 Answers 2


Don't use $$. If you use \begin{equation} and \end{equation} then you'll have numbers automatically generated.

If you want several lines in a row with numbers, you can use the align environment like so:

  \cos^2 \theta + \sin^2 \theta &= 1 \\
  \sin\left(\theta + \frac{\pi}{2}\right) &= \cos \theta

This requires the amsmath package.

You may recognise this code from my answer to your other question.

Here is some sample code that shows these basics:

Here is some text.
    e^{i\pi}+1=0 \tag{Euler}\label{eq:euler}
Some more text.
  \cos^2 \theta + \sin^2 \theta &= 1 \\
  \sin\left(\theta + \frac{\pi}{2}\right) &= \cos \theta \label{eq:trig}

I can refer to the line I have labelled like so: \ref{eq:trig}.
Or if I'd rather have the number enclosed in parentheses: \eqref{eq:trig}.
Also, if I refer to an equation I have ``tagged'' then I get the text of the tag: \eqref{eq:euler}.

Required reading:

  • A tip from me to SoftTimur: Unless you intentionally make displayed equations begin in a new paragraph (that I regard it as a bad practice), make sure there is no a blank line between text and displayed equations. Aug 3, 2011 at 14:44

see http://mirror.ctan.org/info/math/voss/mathmode/Mathmode.pdf, there you'll find a lot of examples and also why using the TeX style $$...$$ isn't a good choice.

  • 1
    Aha. I was looking for that mathmode pdf. Do you mind If I add it to my list of "required reading" in my answer?
    – Seamus
    Aug 3, 2011 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .