# Equation alignement with different numbers of columns - spacing issues

Good day everyone.

I have a set of 4 equations, that have respectively 2, 1, 3 and 3 columns, and that I want to "align" with each other in a particular way. I want all to be centered with respect to the page and the two lasts (with 3 columns) to be aligned with each other. Here are two unsuccessful attempts I made.

First trial:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{subequations}
\begin{align}
[P_\mu, P_\nu] &= 0, &
[M_{\mu\nu}, P_\lambda] &= \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
\end{align}
\begin{align}
[M_{\mu\nu}, M_{\lambda\sigma}]
&= \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma} - \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
\end{align}
\begin{align}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu, &
\varepsilon(P_\mu) &= 0, &
S(P_\mu) &= - P_\mu, \\
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, &
\varepsilon(M_{\mu\nu}) &= 0, &
S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{align}
\label{eq:poincare_hopf_alg}
\end{subequations}

\end{document}


This one is perfect but there are extra vertical spacing between the align environment... Note that I don't want to use this solution with \vspace{-20pt}, or equivalent, because vertical spacing of equations is automatically generated by LaTeX: in other words I would have to change the value of the spacing each time I change my code.

Second trial:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{subequations}
\begin{gather}
\begin{aligned}
[P_\mu, P_\nu] &= 0, &
[M_{\mu\nu}, P_\lambda] &= \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
\end{aligned} \\
\begin{aligned}
[M_{\mu\nu}, M_{\lambda\sigma}]
&= \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma} - \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
\end{aligned} \\
\begin{aligned}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu, &
\varepsilon(P_\mu) &= 0, &
S(P_\mu) &= - P_\mu,
\end{aligned} \\
\begin{aligned}
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, &
\varepsilon(M_{\mu\nu}) &= 0, &
S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{aligned}
\end{gather}
\end{subequations}

\end{document}


Here, the vertical spacing is correct but the horizontal one is not. I want my equation to be equally separated on the width of the page, just like align does (see trial 1).

EDIT 1: My question seemed not so clear so let me precise. When I use align alone with multiple columns, LaTeX makes sure to divide the page width equally for each column (it kind of "justify" the equation). But now I have a block of equations with different numbers of column. I want some to be aligned (like the third and fourth) and the other to be centered/"justified".

I proposed a possible solution based on Celdor proposed command line \vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}. Other more automatic way of doing this are welcome.

\begin{subequations}
\begin{align}
[P_\mu, P_\nu] &= 0, &
[M_{\mu\nu}, P_\lambda] &= \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
\end{align}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{align}
[M_{\mu\nu}, M_{\lambda\sigma}]
&= \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma} - \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
\end{align}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{align}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu, &
\varepsilon(P_\mu) &= 0, &
S(P_\mu) &= - P_\mu, \\
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, &
\varepsilon(M_{\mu\nu}) &= 0, &
S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{align}
\end{subequations}


EDIT 2: I realized my question was related to the unsatisfactorilly answered question.

Third trial:

\begin{subequations}
\begin{alignat}{2}
&a = 0,
&
\mathllap{[M_{\mu\nu}, P_\lambda] = \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,}
\\
&b = 0,
\end{alignat}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{align}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu,           &      \varepsilon(P_\mu) &= 0, &      S(P_\mu) &= - P_\mu, \\
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, & \varepsilon(M_{\mu\nu}) &= 0, & S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{align}
\end{subequations}


• Welcome to TeX.SE! Sep 8, 2022 at 11:01

Something like this?

Example 1.

Code to the Example 1.

\documentclass{article}
\usepackage{mathtools}
\usepackage{kantlipsum}

\begin{document}
\kant*[1][1-2]
\begin{subequations}
\begin{alignat}{2}
&[P_\mu, P_\nu] = 0,
&
\mathllap{[M_{\mu\nu}, P_\lambda] = \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,}
\\
&[M_{\mu\nu}, M_{\lambda\sigma}] = \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma} - \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
\end{alignat}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{align}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu,           &      \varepsilon(P_\mu) &= 0, &      S(P_\mu) &= - P_\mu, \\
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, & \varepsilon(M_{\mu\nu}) &= 0, & S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{align}
\end{subequations}

\kant[1][1]
\end{document}


Update.
Below are added two examples which demonstrate a usage of flalign ("full length alignment") to horizontally justify and distribute equations over the page.

\ineqskip is a macro with \vspace{...} to work out space between separate environments and maintain continuation between equations. The components are

• \abovedisplayskip and \belowdisplayskip--glues added before and after each equation environment
• \baselineskip is a space between two subsequent lines, and
• \jot is space between subsequent lines within an equation environment.

Additionally, \abovedisplayskip and \belowdisplayskip seem to be affected by \baselinestretch and are therefore multiplied by the latter factor.

Example 2.

Example 3

Code to the Example 2

\documentclass{article}
\usepackage{mathtools}
\usepackage{kantlipsum}

\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.2pt}
\renewcommand{\ShowFrameColor}{\color{red}}

\newcommand\ineqskip{
\dimen0=\dimexpr+\abovedisplayskip+\belowdisplayskip\relax
\vspace*{\dimexpr-\baselinestretch\dimen0-\baselineskip+\jot}}

\begin{document}
\begin{subequations}
\begin{align}
[P_\mu, P_\nu] &= 0, &
[M_{\mu\nu}, P_\lambda] &= \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
\end{align}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{align}
[M_{\mu\nu}, M_{\lambda\sigma}]
&= \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma} - \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
\end{align}%
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip-\baselineskip+\jot}%
\begin{flalign}
\Delta(P_\mu) &= P_\mu \otimes 1 + 1 \otimes P_\mu, &
\varepsilon(P_\mu) &= 0, &
S(P_\mu) &= - P_\mu, \\
\Delta(M_{\mu\nu}) &= M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, &
\varepsilon(M_{\mu\nu}) &= 0, &
S(M_{\mu\nu}) &= - M_{\mu\nu},
\end{flalign}
\end{subequations}
\end{document}


Code to the Example 3

\documentclass{article}
% ... preamble is the same as in the Example 2

\begin{document}
\begin{subequations}
\begin{flalign}
[P_\mu, P_\nu] &= 0, &
[M_{\mu\nu}, P_\lambda] &= \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
\end{flalign}%
% ... the rest of the middle part is the same as in Example 2
\end{subequations}
\end{document}

• Hello Celdor, and thank you very much for your answer ! The display in my particular case works fine indeed, but let me be picky. You aligned all equations so that it looks like what I want, but I want that "solitary" equations (first and second) are aligned only with respect to the page width and the two other equations (third and fourth) to be aligned with respect to the other. Let me know if I am not clear. By the way, can you detail what are \mathllap and the arguments of your \vspace ? Sep 9, 2022 at 8:16
• "I want that "solitary" equations (first and second) are aligned only with respect to the page width" and this means you want them centred, separately? So actually the second attempt is correct regarding first two equations? Sep 9, 2022 at 10:07
• I cannot figure out why the other two equations (3rd and 4th) are wrong. If I refer to your answer, the first attempt is perfect apart from the extra spacing. I can see equations form three columns in two rows and each column is aligned by =. How do you want them to be aligned with each other if centring is wrong and aligning by = is also wrong? Sep 9, 2022 at 10:08
• \mathrlap{} is a class of macros that instructs LaTeX to create a box of zero length while the content is still typeset. Then, its argument is pushed towards left. It is useful if you don't want the content to create unnecessary space in aligned equations (here is an article). The \vspace{} simply takes negative space created by two consecutive equations. Sep 9, 2022 at 10:16
• Thanks for your time and answers ! I edited my question to precise what I meant. Also you can check my third example to see why I was picky. Sep 9, 2022 at 12:26

You can use \IEEEeqnarray from IEEEtrantools. See a manual at https://moser-isi.ethz.ch/docs/typeset_equations.pdf

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

\begin{document}
\begin{subequations}\label{eq:poincare_hopf_alg}
\begin{IEEEeqnarray}{rCl ' rCl ' rCl}
\IEEEeqnarraymulticol{9}{c}{
[P_\mu, P_\nu] = 0,
\hspace{4em}
[M_{\mu\nu}, P_\lambda] = \eta_{\nu\lambda} P_\mu - \eta_{\mu\lambda} P_\nu,
} \\
\IEEEeqnarraymulticol{9}{c}{
[M_{\mu\nu}, M_{\lambda\sigma}]
= \eta_{\mu\sigma} M_{\nu\lambda} + \eta_{\nu\lambda} M_{\mu\sigma}
- \eta_{\mu\lambda} M_{\nu\sigma} - \eta_{\nu\sigma} M_{\mu\lambda},
} \\
\Delta(P_\mu) &=& P_\mu \otimes 1 + 1 \otimes P_\mu, &
\varepsilon(P_\mu) &=& 0, &
S(P_\mu) &=& - P_\mu, \\
\Delta(M_{\mu\nu}) &=& M_{\mu\nu} \otimes 1 + 1 \otimes M_{\mu\nu}, &
\varepsilon(M_{\mu\nu}) &=& 0, &
S(M_{\mu\nu}) &=& - M_{\mu\nu},
\end{IEEEeqnarray}
\end{subequations}

\end{document}
`