# Change the numbering of equations with floating equation

I an trying to change the numbering of the equations in my document. The reason is that I have a 'floating' equation that always needs to be on top of the page, but I want it to be numbered according to how it logically appears in the text. Because it floats, I have to put it earlier on in the text, but that makes that the number is lower than it logically should be.

This is what I mean:

\documentclass{article}
\begin{document}

\begin{figure*}[!t]
% This is an equation that floats on top of the page.
% I want it to be numbered '2'.
$$\label{eq:Eq2} 4 + 5 = 9.$$
\hrulefill
\end{figure*}

\noindent Here comes some text, then the first equation.
$$\label{eq:Eq1} 1 + 2 = 3.$$
Here comes text that refers to the second equation, which should float on top of this page. The number should still be 2', but it is \ref{eq:Eq2}.
$$\label{eq:Eq3} 6 + 7 = 13.$$
How do I adjust it such that the following gives 1, 2, 3''? With {\verb \ref }: \ref{eq:Eq1}, \ref{eq:Eq2}, \ref{eq:Eq3}

\end{document}


This produces the following:

So as mentioned in the text, I would like that the numbering of equations runs (2), (1), (3). Can this be done?

Your assumption that "Because it floats, I have to put it earlier on in the text" is not correct. Place it at the point you want to refer to and it will float to the top of the current page, provided there is space and there are not too many floats fighting for that position:

\documentclass{article}
\begin{document}

\noindent Here comes some text, then the first equation.
$$\label{eq:Eq1} 1 + 2 = 3.$$
\begin{figure*}[t]
$$\label{eq:Eq2} 4 + 5 = 9.$$
\hrulefill
\end{figure*}%
Here comes text that refers to the second equation, which should float
on top of this page. The number should still be 2', and indeed it is
\ref{eq:Eq2}.
$$\label{eq:Eq3} 6 + 7 = 13.$$
So we get references 1, 2, 3'' with \verb+\ref+: \ref{eq:Eq1},
\ref{eq:Eq2}, \ref{eq:Eq3}.

\end{document}


If things fall at a page break, you still get the requested numbering:

(equation 2 at top of next page)

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\lipsum[1-4]

Text.

Text.

\noindent Here comes some text, then the first equation.
$$\label{eq:Eq1} 1 + 2 = 3.$$
\begin{figure*}[t]
$$\label{eq:Eq2} 4 + 5 = 9.$$
\hrulefill
\end{figure*}%
Here comes text that refers to the second equation, which should float
on top of this page. The number should still be 2', and indeed it is
\ref{eq:Eq2}.
$$\label{eq:Eq3} 6 + 7 = 13.$$
So we get references 1, 2, 3'' with \verb+\ref+: \ref{eq:Eq1},
\ref{eq:Eq2}, \ref{eq:Eq3}.

\end{document}

• +1 for the comment that it's not needed, although the MWE used figure* which makes me suspect the real case is 2-column (as that's the usual way to fit a wide equation) 2-column figures never go to the top of the current page. – David Carlisle Sep 1 '13 at 13:36
• Whereas this is correct in this example, I'm afraid that the minimal working example in this case hides the real problem: in my actual text, when I place it where it should appear, the floating equation appears on the next page, so the numbering is again out of place. – Jelle Sep 1 '13 at 14:00
• Can you please clarify. Assuming you put nothing but text before the sample above, the floating equation gets the number 2' regardless of which page it is placed on. Is that not what you want? – Andrew Swann Sep 1 '13 at 14:10

You can adjust them by hand depending on where the float lands.

\documentclass{article}
\begin{document}

\begin{figure*}[!t]
% This is an equation that floats on top of the page.
% I want it to be numbered '2'.
\setcounter{equation}{1}%
$$\label{eq:Eq2} 4 + 5 = 9.$$
\hrulefill
\end{figure*}

\setcounter{equation}{0}%
\noindent Here comes some text, then the first equation.
$$\label{eq:Eq1} 1 + 2 = 3.$$
Here comes text that refers to the second equation, which should float on top of this page. The number should still be 2', but it is \ref{eq:Eq2}.%
\setcounter{equation}{2}%
$$\label{eq:Eq3} 6 + 7 = 13.$$
How do I adjust it such that the following gives 1, 2, 3''? With {\verb \ref }: \ref{eq:Eq1}, \ref{eq:Eq2}, \ref{eq:Eq3}

\end{document}
`
• ans hope that it's not necessary to add another numbered equation in between. this is something that should be done only at the very last minute, after everyone who has the right to make comments has signed off. and if this is submitted to a journal that has "intrusive" editing as part of its production procedures, be prepared to check the proof (if you get proof!) very carefully to make sure nothing has gone wrong. – barbara beeton Sep 1 '13 at 13:55
• This is indeed a good solution as a last resort. :-) In my case, it's indeed for a final-final paper, so it should be all right. – Jelle Sep 1 '13 at 14:12