# Renaming label names in AucTex to recover ordered sequence

By rearranging (copy-and-pasting) math environments the automatically RefTeX generated label numbers

\begin{align}
\label{eq:5}
...
\end{align}

texttexttext...

\begin{align}
\label{eq:3}
...
\end{align}


become shuffled which makes the referencing to individual equations difficult.

How it is possible to rename the label names so that an increasing order is recovered?

-
Much of the point of the \label / \ref system is that you can use labels that are meaningful to you, rather than being a random number, and then LaTeX sorts out the numbering for you. I would recommend using e.g. a label such as eq:Einstein for the Einstein equation, instead of numbered labels. –  Andrew Swann Jan 8 '13 at 14:32
@AndrewSwann Reftex allows you to insert labels with context information (using C-c C-) ), which, together with automatic numbering, makes the key of the label more or less useless. –  T. Verron Jan 8 '13 at 14:43
@T.Verron I use that mechanism of reftex all the time, but find itvery helpful to have keys that have meaningful names when working with my source. –  Andrew Swann Jan 8 '13 at 20:53

I like how you asked "how is it possible to..." instead of "is it possible to...". Because of course it is possible, reftex being awesome and OCD-friendly. :)
reftex-renumber-simple-labels is an interactive autoloaded Lisp function.
So... M-x reftex-renumber-simple-labels RET y and you are done. It should even work across files. Note that you will get an error if the labels are already ordered, though.