I would like to define a new equation environment that displays the equation inline, but with its number being displayed at the end of the line (without text between them).
More concretely, the following code:
The quick brown fox jumps over the lazy dog. We have
\begin{equation-inline}
a + b + c = d.
\end{equation-inline}
Therefore, ...
should output something like this:
Motivation: I am writing a document with some space constraints and I would be able to save a few lines by replacing some display-style centered equations with the above.
There have been quite a lot of questions on labeled inline equations, for example this one or this one, but my question is a bit different: I would like the equation number to be displayed at the end of the line so that it can be easily located.
Thank you in advance for your help!
Update:
With the following definition of equation-inline
, the equation is displayed correctly but referencing to it doesn't work:
\documentclass{article}
\usepackage{amsmath}
\newenvironment{equation-inline}{$\stepcounter{equation}}{$\hfill(\theequation)\\}
\begin{document}
The quick brown fox jumps over the lazy dog. We have
\begin{equation-inline}\label{eq:x}
a + b + c = d.
\end{equation-inline}
According to~\eqref{eq:x}, we have...
\end{document}
Update 2:
Replacing \stepcounter{equation}
in the above with \refstepcounter{equation}
works (credit):
\newenvironment{equation-inline}{
% Put \refstepcounter at the beginning, because
% package `hyperref' sets the anchor here.
\refstepcounter{equation}%
$}{
$\hfill(\theequation)\\}