3

Short description:

The order of appearance of the equations in the text of my document is different from the order of appearance of the equations in my tex-document. Normally, the equation numbering follows the order of appearance in the tex-document. However, I want the numbering to follow the order of appearance in the text. How can I change my equation numbers such that they match the order of appearance in the text?

Detailed description:

My document has several very long equations, which are wider than the allowed text width of the document. These long equations appear at multiple locations throughout the document, as in the following example (MWE1).

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{lscape}

\begin{document}

\lipsum[1]
\textbf{First reference of \eqref{eq:a}.}
\begin{equation} \label{eq:a}
A = aaaaaa
\end{equation}

\lipsum[2]
\textbf{First reference of \eqref{eq:b}.}
\begin{equation} \label{eq:b}
B = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
\end{equation}

\lipsum[3]
\textbf{First reference of \eqref{eq:c}.}
\begin{equation} \label{eq:c}
C = cccccc
\end{equation}

\lipsum[4]
\textbf{First reference of \eqref{eq:d}.}
\begin{equation} \label{eq:d}
D = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
\end{equation}

\lipsum[5]
\textbf{First reference of \eqref{eq:e}.}
\begin{equation} \label{eq:e}
E = eeeeee
\end{equation}

\lipsum[6]
\textbf{First reference of \eqref{eq:f}.}
\begin{equation} \label{eq:f}
F = fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
\end{equation}

\end{document}

My preferred solution to this problem is to put all the long equations together on a single landscape page, as in the following example (MWE2).

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{lscape}

\begin{document}

\lipsum[1]
\textbf{First reference of \eqref{eq:a}.}
\begin{equation} \label{eq:a}
A = aaaaaa
\end{equation}

\lipsum[2]
\textbf{First reference of \eqref{eq:b}.}
\begin{landscape}
\begin{align}
B &= bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
\label{eq:b}
\\[40mm]
D &= ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
\label{eq:d}
\\[40mm]
F &= fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
\label{eq:f}
\end{align}
\end{landscape}

\lipsum[3]
\textbf{First reference of \eqref{eq:c}.}
\begin{equation} \label{eq:c}
C = cccccc
\end{equation}

\lipsum[4]
\textbf{First reference of \eqref{eq:d}.}

\lipsum[5]
\textbf{First reference of \eqref{eq:e}.}
\begin{equation} \label{eq:e}
E = eeeeee
\end{equation}

\lipsum[6]
\textbf{First reference of \eqref{eq:f}.}
\end{document}

This however changes the equation numbering, such that it no longer agrees with the equations' order of appearance in the text.

Q: How can the equation numbers in MWE2 be changed, such that they are again as they were in MWE1? I am unable to come up with a solution that avoids hard-coding the equation numbers of the long equations using \tag{nb}.

5
  • Do you mean that the three equations in the landscape page should be numbered as (2), (4) and (6)?
    – campa
    Oct 30 '20 at 12:30
  • Exactly. And I'd like the other equations to be numbered as (1), (3), and (5).
    – jverdyck
    Oct 30 '20 at 12:52
  • Just to be sure: you do know that your readers will hate you, do you? ;-)
    – campa
    Oct 30 '20 at 12:55
  • I'm not counting on having too many readers ;-)
    – jverdyck
    Oct 30 '20 at 13:00
  • Other suggestions to solve my 'core problem' of having too long equations are of course welcome as well. But I'd be very interested in answers to my specific question about how to renumber my equations.
    – jverdyck
    Oct 30 '20 at 13:02
3

Here's a possible implementation. At the point where you'd insert the long equation, you write \sethere{<label>} and the equation will use \taghere{<label>} instead of \label.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{pdflscape}

\newcommand{\sethere}[1]{\refstepcounter{equation}\label{#1}}
\newcommand{\taghere}[1]{\tag{\ref{#1}}}

\begin{document}

Note for the reader: some long equation appear on the
dedicated page~\pageref{longequations}

\lipsum[1]
\textbf{First reference of \eqref{eq:a}.}
\begin{equation} \label{eq:a}
A = aaaaaa
\end{equation}

\lipsum[2]
\textbf{First reference of \eqref{eq:b}.}\sethere{eq:b}
\begin{landscape}\label{longequations}
\begin{align}
B &= bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
\taghere{eq:b}
\\[40mm]
D &= ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
\taghere{eq:d}
\\[40mm]
F &= fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
\taghere{eq:f}
\end{align}
\end{landscape}

\lipsum[3]
\textbf{First reference of \eqref{eq:c}.}
\begin{equation} \label{eq:c}
C = cccccc
\end{equation}

\lipsum[4]
\textbf{First reference of \eqref{eq:d}.}\sethere{eq:d}

\lipsum[5]
\textbf{First reference of \eqref{eq:e}.}
\begin{equation} \label{eq:e}
E = eeeeee
\end{equation}

\lipsum[6]
\textbf{First reference of \eqref{eq:f}.}\sethere{eq:f}
\end{document}

Probably it's better to set the long equations at end, but it's your decision.

enter image description here

2

You can use \setcounter{equation}{<new>} to specify that the next equation will be numbered <new> + 1.

% eqnumprob.tex  SE 568922
\documentclass[a5paper]{article}
\begin{document}
\pagestyle{empty}

Regular sequential equation numbers.

\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

Some out of sequence equation numbers.

\setcounter{equation}{57}
\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

\setcounter{equation}{-23}
\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

Now back to picking up the initial regular sequence numbers.

\setcounter{equation}{2}
\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}

\begin{equation}
x' + y^{2} = z_{j}^{2}
\end{equation}


\end{document}

enter image description here

1

If you only care about how it looks printed: Use \refstepcounter{equation} right before where you first refer to them, and then \tag the equation with the label.

If you use \hyperref this will however be a very bad idea.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{lscape}

\begin{document}

\lipsum[1]
\textbf{First reference of \eqref{eq:a}.}
\begin{equation} \label{eq:a}
A = aaaaaa
\end{equation}

\lipsum[2]
\refstepcounter{equation}
\label{eq:b}
\textbf{First reference of \eqref{eq:b}.}
\begin{landscape}
\begin{align}
B &= bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
\tag{\ref{eq:b}}
\\[40mm]
D &= ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
\tag{\ref{eq:d}}
\\[40mm]
F &= fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
\tag{\ref{eq:f}}
\end{align}
\end{landscape}

\lipsum[3]
\textbf{First reference of \eqref{eq:c}.}
\begin{equation} \label{eq:c}
C = cccccc
\end{equation}

\lipsum[4]
\refstepcounter{equation}
\label{eq:d}
\textbf{First reference of \eqref{eq:d}.}

\lipsum[5]
\textbf{First reference of \eqref{eq:e}.}
\begin{equation} \label{eq:e}
E = eeeeee
\end{equation}

\lipsum[6]
\refstepcounter{equation}
\label{eq:f}
\textbf{First reference of \eqref{eq:f}.}
\end{document}

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.