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 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!

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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:

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

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:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Here is some text.
  \begin{equation}
    e^{i\pi}+1=0 \tag{Euler}\label{eq:euler}
  \end{equation}
Some more text.
\begin{align}
  \cos^2 \theta + \sin^2 \theta &= 1 \\
  \sin\left(\theta + \frac{\pi}{2}\right) &= \cos \theta \label{eq:trig}
\end{align}

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}.
\end{document}

Required reading:

share|improve this answer
    
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. –  xport Aug 3 '11 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.

share|improve this answer
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 '11 at 14:27
    
Thanks for your comment –  SoftTimur Aug 5 '11 at 21:54

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.