Equation number messes with horizontal alignment
In the “centered equations with tags on the right” mode, the “indent” from the left margin to the align structure should only be accepted when it is decreasing. Unfortunately, the macro \x@calc@shift@rc
for this mode does not guard against a possible increasing “indent”. Your example shows how the “indent” increases from (9) to (10).
\documentclass{article}
\usepackage{amsmath,lipsum}
\usepackage{etoolbox}
\makeatletter
\patchcmd\x@calc@shift@rc
{% The \eqnshift@ could end up increasing!
\eqnshift@\displaywidth
\advance\eqnshift@-\@tempdima
\advance\eqnshift@-\@tempcntb\alignsep@
\global\divide\eqnshift@\tw@
}
{% Use \dimen@ to perform the calculations instead
\dimen@\displaywidth
\advance\dimen@-\@tempdima
\advance\dimen@-\@tempcntb\alignsep@
\divide\dimen@\tw@
% Update \eqnshift@ if and only if the result decreases
\ifdim\dimen@<\eqnshift@
\global\eqnshift@\dimen@
\fi
}
{}
{}
\makeatother
\begin{document}
\setcounter{equation}{8}
\lipsum[1][1-3]
\begin{align}
\nonumber 0
&= \framebox[325pt]{line} \\
&= \framebox[295pt]{line}
\end{align}
\lipsum[1][4-6]
\begin{align}
\nonumber 0
&= \framebox[325pt]{line} \\
&= \framebox[295pt]{line}
\end{align}
\lipsum[1][7-9]
\end{document}
Addendum: I have reported the fix on the GitHub issue tracker.
Use a phantom
option inside \adjustbox
command to create a phantom tag as follows
\adjustbox{phantom}{(\arabic{equation})}
If you plan to use this frequently define a \tagphantom
command
\newcommand{\tagphantom}{\adjustbox{phantom}{(\arabic{equation})} \notag}
\documentclass{article}
\usepackage{amsmath,lipsum}
\usepackage{adjustbox}
\newcommand{\tagphantom}{\adjustbox{phantom}{(\arabic{equation})} \notag}
\begin{document}
\setcounter{equation}{8}
\lipsum[1][1-3]
\begin{align}
\nonumber 0
&= \framebox[325pt]{line} \\
&= \framebox[295pt]{line}
\end{align}
\lipsum[1][4-6]
\begin{align}
&= \framebox[295pt]{line} \tagphantom \\
&=\framebox[295pt]{line}
\end{align}
\lipsum[1][7-9]
\end{document}
Another way to do it is to use split
whenever you do not want the tag to change the space available for each line in align
, but this will bring the tag to the vertical middle
\documentclass{article}
\usepackage{amsmath,lipsum}
\begin{document}
\setcounter{equation}{8}
\lipsum[1][1-3]
\begin{align}
\nonumber 0
&= \framebox[325pt]{line} \\
&= \framebox[295pt]{line}
\end{align}
\lipsum[1][4-6]
\begin{align}
\nonumber 0
&= \framebox[325pt]{line} \\
&= \framebox[295pt]{line}
\end{align}
\lipsum[1][7-9]
\end{document}