[Tex/LaTex] Controlling exact position of equation numbers

equationsnumbering

I'm using the fleqn option to the amsmath package to position my equations a small fixed distance from the left hand margin, rather than centred. I think it would look better if the equation numbers were slightly indented from the right-hand margin, rather than flush against it as they are by default. So:

How can I control the positioning of the equation numbers? I still want them on the right-hand side, I just want a little space between them and the margin.

Here is a minimal working example to demonstrate the issue:

\documentclass{article}

\usepackage[fleqn]{amsmath}

\setlength{\mathindent}{0.5\parindent} % just a little bit of indentation for the equations

\begin{document}

% long paragraph so that you can see where the margin is:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum. Here is an equation:
\begin{equation}
  \label{euler.eqn}
  \exp\left(\frac{i\tau}{2}\right) = -1 \quad.
\end{equation}
Notice that the equation is indented from the left, but the number \eqref{euler.eqn} 
is not indented from the right.

\end{document}

Best Answer

It is commendable that your equations are so short that you do not need the space.

The following is a hack for the equation of LaTeX, followed by some redefinitions for amslatex. I hope I have caught the cases there, e.g. you do not want to have extra space after \eqref. It uses the same internal tag macros.

\makeatletter
% Patch for LaTeX:
\g@addto@macro\@eqnnum{\kern\mathindent}
% Patches for amslatex:
\let\org@maketag@@@\maketag@@@
\def\maketag@@@#1{%
  \org@maketag@@@{#1}\kern\mathindent
}
\let\org@eqref\eqref
\def\eqref#1{%
  \begingroup
    \mathindent=\z@
    \org@eqref{#1}%
  \endgroup
}
\makeatother