# Giving an equation between 's a number

I usually use $...$ to typeset equations in latex and sometimes I come back and realize that I want to have an equation number and label. I have been coming back and editing it to $$...$$ but this is annoying and time consuming. Is there a command to do something like $\addeqnumber{}$ which will work the same way as the equation environment? I am aware this probably isn't the best practice, but it would save me some annoyance.

-

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$1+1=2 \addtag$

\end{document}

-
Thanks, this is exactly what I wanted! –  Otis Apr 1 '11 at 16:48

Not answering your question but maybe solving your problem: mathtools has a mechanism that suppresses equation numbers for unreferenced equations. (So you'd always use equation and friends and only get numbers if you ref the equation.)

-
This is great! Thanks! –  Otis Apr 1 '11 at 16:50

If you find yourself doing this for all equations I would use search & replace but if you’re reluctant you can do the following:

\let$\equation \let$\endequation

After that, $…$ will behave identical to $$…$$.

You can also wrap this into a macro, and create another one to switch back so that you can switch between the two styles via two macros.

-
This won't handle the numbering appropriately if the amsmath package is loaded. –  Gonzalo Medina Apr 1 '11 at 13:52
@Gonzalo Hmm, weird. What’s the issue? –  Konrad Rudolph Apr 1 '11 at 13:58
If you load amsmath and use your suggestion, all the equations written with $...$ will receive the same numbering: (1). –  Gonzalo Medina Apr 1 '11 at 14:06
this should use \begin etc., see the last few lines of amsmath.sty –  Philipp Apr 1 '11 at 19:25

As you're aware that this isn't best practice, I don't mind answering! The following seems to work:

\refstepcounter{equation}%
\label{#1}%
\let\]\endequation}

Use it as:

$\addlabel{pythagoras} x^2 + y^2 = z^2$

The start of \equation simply steps the counter, so we do that and don't have to worry about doing anything else at the begining. Then we assign the label (since there's no point in having one command to add the number and then another to assign a label to it). To place the label, we use the \endequation command. As we're doing this inside the mathematics, the assignment \let\]\endequation only holds until the end of the mathematics and so it doesn't affect future mathematics (which is a bit lucky for future mathematics).

-
This doesn't work if amsmath is loaded. –  Gonzalo Medina Apr 1 '11 at 13:18
And there's a typo in the definition of \addlabel: it should be \label{#1}, instead of \label{pythagoras}. –  Gonzalo Medina Apr 1 '11 at 13:27
@Gonzalo: (amsmath) Probably not, but the question didn't specify a package and was clearly not looking for a "robust" solution so I didn't spend much effort on it. (pythagoras) Whoops! That was my test case. Still, Leo's looks simplest so I'll not bother sorting out the problems with mine! –  Loop Space Apr 1 '11 at 17:58

To build on Konrad's answer and make it work with amsmath, I'd use:

\let$\myequation \let$\myendequation
-