使用浮动方程更改方程的编号

使用浮动方程更改方程的编号

我正在尝试更改文档中方程的编号。原因是我有一个“浮动”方程,它始终需要位于页面顶部,但我希望根据它在文本中的逻辑显示方式对其进行编号。因为它是浮动的,所以我必须将其放在文本的前面,但这会导致编号低于逻辑上应该的编号。

我的意思是:

\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}

这将产生以下内容:在此处输入图片描述

因此,正如文中提到的,我希望方程的编号为 (2)、(1)、(3)。可以这样做吗?

答案1

您的假设“因为它是浮动的,所以我必须把它放在文本的前面”是不正确的。将它放在您想要引用的位置,它就会浮动到当前页面的顶部,前提是有足够的空间,并且没有太多浮动元素争夺该位置:

示例输出

\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}

如果内容落在分页符处,您仍然可以获得所请求的编号:

样例输出二

(下页顶部的公式 2)

\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}

答案2

您可以根据浮子落下的位置手动调整它们。

\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}

相关内容