[Tex/LaTex] Change the numbering of equations with floating equation

equationsfloatsnumbering

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'.
\begin{equation}\label{eq:Eq2}
    4 + 5 = 9.
\end{equation}
\hrulefill
\end{figure*}

\noindent Here comes some text, then the first equation.
\begin{equation}\label{eq:Eq1}
    1 + 2 = 3.
\end{equation}
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}.
\begin{equation}\label{eq:Eq3}
    6 + 7 = 13.
\end{equation}
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:enter image description here

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

Best Answer

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:

Sample output

\documentclass{article}
\begin{document}

\noindent Here comes some text, then the first equation.
\begin{equation}\label{eq:Eq1}
    1 + 2 = 3.
\end{equation}
\begin{figure*}[t]
\begin{equation}\label{eq:Eq2}
    4 + 5 = 9.
\end{equation}
\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}.
\begin{equation}\label{eq:Eq3}
    6 + 7 = 13.
\end{equation}
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:

Sample output two

(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.
\begin{equation}\label{eq:Eq1}
    1 + 2 = 3.
\end{equation}
\begin{figure*}[t]
\begin{equation}\label{eq:Eq2}
    4 + 5 = 9.
\end{equation}
\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}.
\begin{equation}\label{eq:Eq3}
    6 + 7 = 13.
\end{equation}
So we get references ``1, 2, 3'' with \verb+\ref+: \ref{eq:Eq1},
\ref{eq:Eq2}, \ref{eq:Eq3}.

\end{document}