# Specific Formulas Alignment

I need to align congruences in different ways in columns. The left parts of the formulas (in the red frame) need align in the center, the right ones (in the green frame) should be one under the other (at the same distance from the left ones). All formulas must be numbered (blue frame), I can't put only one number for all.

For two congruences I came up with this solution:

\newlength{\lenone}
\newlength{\lentwo}
\settowidth{\lenone}{$a + b + c + d + e + f \equiv a + b + c + d + e + f$}
\settowidth{\lentwo}{$a^2 + b + c \equiv 1$}
\setlength{\lenone}{0.5\dimexpr\lenone-\lentwo\relax}

\begin{align}
\begin{array}{ccl}
a^2 + b + c \equiv 1 & \makebox[\lenone]{} & \pmod n,
\end{array}\\
\begin{array}{cl}
a + b + c + d + e + f \equiv a + b + c + d + e + f & \pmod n.
\end{array}
\end{align}


The lengths of both formulas are calculated, and then half of their difference is inserted into \makebox, pushing the smaller formula aside to the left.

Is there any better solution for this problem? If there is no ready-made solution then how can I program my own new environment in which there can be an arbitrary number of lines (for example, separated by \\) with the specified properties?

I want:

\begin{myalign}{cl}
a^2 + b + c \equiv 1                               & \pmod n,\\
a + b + c + d + e + f \equiv a + b + c + d + e + f & \pmod n,\\
a + b - b = \equiv a                               & \pmod n.
\end{myalign}


\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tabularx}

\begin{document}
I always thought that mathematical convetion was to align on equal signs,
or in this case on the \verb!\equiv! sign

\begin{alignat}{3}
a^2 + b + c &\equiv 1  &  \pmod{n},&\label{aa}\\
a + b + c + d + e + f &\equiv a + b + c + d + e + f\quad  &pmod{n},
&\label{bb}\\
a + b - b &\equiv a & \pmod{n}&\label{cc}.
\end{alignat}
If you don't want to align at the \verb!\equiv!

\bigskip
\noindent
\begin{tabularx}{\textwidth}{>{\hfil$}X<{$} >{$}c<{$}
>{\refstepcounter{equation}(\theequation)}r  @{}}
a^2 + b + c \equiv 1  &\pmod{n},&\label{dd}\\
a + b + c + d + e + f \equiv a + b + c + d + e + f &
\pmod{n},&\label{ee}\\
a + b - b \equiv a & \pmod{n}, & \label{ff}
\end{tabularx}

\end{document}


I'd go with IEEEeqnarray from IEEEtrantools.

\documentclass{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}

\begin{document}

\begin{IEEEeqnarray}{cl}
a^2 + b + c \equiv 1                               & \pmod{n},\\
a + b + c + d + e + f \equiv a + b + c + d + e + f & \pmod{n},\\
a + b - b \equiv a                                 & \pmod{n}.
\end{IEEEeqnarray}

\end{document}


I recommend to avoid \pmod n, because it might suggest that \pmod 19 is correct (it isn't): the modulo of the congruence is the argument to \pmod.