Based on @egreg's answer, this is what I came up with. It basically defines \gatherleft
and \gatherright
commands that are consistent in spacing with \multline
, even with varying lengths of equation numbers (including tags).
It also works with different font sizes, so the 20pt
seem to be pretty constant. If anyone knows what those correspond to, I would be happy to modify my answer accordingly.
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
% Left-/right-aligned lines in gather, with spacing consistent with multline.
% Limitations: \tag{...}, if used, has to come BEFORE corresponding \gatherleft or \gatherright
\makeatletter
\newlength{\gatherlabelwidth}
\newcommand{\gatherbox}[2]{
\settowidth{\gatherlabelwidth}{%
\iftag@%
\df@tag%
\else%
\stepcounter{equation}%
\print@eqnum%
\addtocounter{equation}{-1}%
\fi%
}
\makebox[\displaywidth - \gatherlabelwidth - 20pt][#1]{$\displaystyle #2$}
}
\makeatother
\newcommand{\gatherleft}[1]{\gatherbox{l}{#1}}
\newcommand{\gatherright}[1]{\gatherbox{r}{#1}}
% for this MWE only:
\newcommand{\reset}{
\setbox0=\vtop{\begin{multline}a\\b\\c\end{multline}}
\setlength{\mytempheight}{\ht0}
\addtolength{\mytempheight}{\dp0}
\color{red}\vspace*{-\mytempheight}\vspace*{-0.5\baselineskip}}
\usepackage{color}
\newlength{\mytempheight}
\def\countervalue{0}
\newif\ifusetag
\begin{document}
% Test some variations by uncommenting any line:
% \tiny
% \LARGE
% \def\countervalue{6}
% \def\countervalue{7}
% \def\countervalue{8}
% \def\countervalue{9}
% \def\countervalue{96}
% \def\countervalue{97}
% \def\countervalue{98}
% \def\countervalue{99}
% \usetagtrue
This is typeset with multline:
\setcounter{equation}{\countervalue}\stepcounter{equation}\stepcounter{equation}
\begin{multline}
a\\b\\c
\ifusetag
\tag{my tag!}
\else\fi
\end{multline}
\reset
This is typeset with gather:
\setcounter{equation}{\countervalue}
\begin{gather}
\gatherleft{a} \\
b \\
\ifusetag
\tag{my tag!}
\else\fi
\gatherright{c}
\end{gather}
\end{document}

multline
. The manual says "Likeequation
,multline
has only a single equation number".gather
.gather
, "while maintaining the overall layout thatmultline
offers".\shoveleft
and\shoveright
commands pfovided bymathtools
only work withmultlined
(which is the "internal" equivalent ofmultline'), so they're no help. the only suggestion i can make offhand, then, is to add large
\hspace*s to adjust the positioning of individual lines. requesting extending the applicability of the
\shove...` commands seems not unreasonable.