# Strange centring problem of side by side equations in an enumerate environment

I'm facing a problem in centring two side by side equations correctly inside an enumerate environment.

This problem only occurs to me under certain conditions and I can't get my head around it. Consider the following MWE (it is long but unfortunately it's necessary):

\documentclass[12pt]{article}
\usepackage[showframe]{geometry} % Makes it easier to spot the problem but is unnecessary

\usepackage{amsmath}
\numberwithin{equation}{section}

\makeatletter
\newcommand{\displaybump}{\hbox to \@totalleftmargin{\hfil}}
\makeatother

\usepackage[final]{hyperref}
\hypersetup{
filecolor=black,
urlcolor=black,
}
\urlstyle{same}

\AtBeginDocument{\let\latexlabel\label}

\begin{document}

\section{First Section}
$$abcde=fghij$$
\begin{equation*}
\refstepcounter{equation}\latexlabel{firsthalf}
\refstepcounter{equation}\latexlabel{secondhalf}
\tag{\ref*{firsthalf}, \ref*{secondhalf}}
\end{equation*}
some text some text some text some text some text some text:

\begin{enumerate}
\item Some text some text some text some text some text some text some text some text
$$abcde=fghij$$
$$abcde=fghij \displaybump$$

\item Some text some text some text some text some text some text some text some text
\begin{equation*}
\refstepcounter{equation}\latexlabel{indented firsthalf}
\refstepcounter{equation}\latexlabel{indented secondhalf}
\tag{\ref*{indented firsthalf}, \ref*{indented secondhalf}}
\end{equation*}
\begin{equation*}
\refstepcounter{equation}\latexlabel{not indented firsthalf}
\refstepcounter{equation}\latexlabel{not indented secondhalf}
\tag{\ref*{not indented firsthalf}, \ref*{not indented secondhalf}}
\end{equation*}
\begin{equation*}
\refstepcounter{equation}\latexlabel{wrongly centred firsthalf}
\refstepcounter{equation}\latexlabel{wrongly centred secondhalf}
\tag{\ref*{wrongly centred firsthalf}, \ref*{wrongly centred secondhalf}}
\end{equation*}
\end{enumerate}

\end{document}


That compiles to:

I've taken the code for side by side equations from @egreg 's answer here: Equations side-by-side, both numbers on the right and the code for correctly centre equations of an item from @PhilHirschhorn 's answer here: How can I center text/math inside a list environment?.

As can be seen, the command to correctly centre an equation in an enumerate environment respect to the page margins properly works for the side by side equations 1.8 and 1.9, but it fails for the side by side equations 1.10 and 1.11. However, by shortening the equations or by setting 10pt instead of 12pt it returns to work properly, that leads me to think that the problem is somehow related to the total length of the two equations plus their captions.

By correctly centring the two side by side equations in an enumerate environment respect to the page margins I mean that the space between the left margin and the beginning of the first of the two equations must be equal to the space between the end of the last equation and the right margin of the page, not the space between the end of the last equation and the beginning of the captions as it occurs for equations 1.10 and 1.11.

How can I fix that?

Thank you for your time, it is very appreciated.

• You could use the accepted and higher ranked solution (\hspace*{-\leftskip}) instead of the "crude" \displaybump approach. – John Kormylo Feb 11 at 15:25
• @JohnKormylo Thanks for the suggestion, it is exactly what I've done, I've now posted an answer. I needed to modify the definition of the \MLine{} command a bit. – Edoardo Serra Feb 11 at 15:31

The error is given by the \displaybump command, which, for some to me obscure reason, fails in the circumstances described above.
\def\MLine#1{\par\hspace*{-\leftmargin}\parbox{\textwidth}{

The correct result can be achieved by simply putting inside the \MLine{} command what before was inside the equation* environment.