8

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?

6

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}
  • 1
    +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
2

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

\setcounter{equation}{0}%
\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}.%
\setcounter{equation}{2}%
\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}
  • 2
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.