Aligning the entries of two matrices vertically

I suggest you (a) load the mathtools package, (b) use {bmatrix*}[r] environments instead of bmatrix environments, and (c) use one \phantom{-} instruction each in columns 2 and 3 of the third matrix, to equalize the widths of these columns with the columns of the matrix that hovers above it.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'bmatrix*' env.
\begin{document}
    \[
    \begin{aligned}
            &
            \begin{bmatrix*}[r]
            1&1&0\\
            1&0&1\\
            1&-1&0\\
            1&0&-1      
            \end{bmatrix*}
            \\
            \begin{bmatrix*}[r]
            1&1&1&1\\
            1&0&-1&0\\
            0&1&0&-1
            \end{bmatrix*}
            &
            \begin{bmatrix*}[r]
            4&\phantom{-}0&\phantom{-}0\\
            0&2&0\\
            0&0&2
            \end{bmatrix*}
    \end{aligned}
    \] 
\end{document}

If you prefer the centered alignment, the tabstackengine package allows the fixing of all column widths to the widest in the matrix. This way, you only need to pad a single element of the narrower matrix to bring them to a common width:

\documentclass{article}
\usepackage{amsmath,tabstackengine}
\setstacktabbedgap{10pt}
\begin{document}
    \[
    \fixTABwidth{T}
    \begin{aligned}
            &
            \bracketMatrixstack{
            1&1&0\\
            1&0&1\\
            1&-1&0\\
            1&0&-1      
            } 
            \\
            \bracketMatrixstack{
            1&1&1&1\\
            1&0&-1&0\\
            0&1&0&-1
            } 
            &
            \bracketMatrixstack{
            4&0&0\\
            0&2&0\\
            0&0&\mkern7mu 2\mkern7mu
            }   
    \end{aligned}
    \] 
\end{document}

enter image description here

If right alignment is preferred, a single \phantom{-} is necessary:

\documentclass{article}
\usepackage{amsmath,tabstackengine}
\setstacktabbedgap{10pt}
\begin{document}
    \[
    \fixTABwidth{T}
    \begin{aligned}
            &
            \bracketMatrixstack[r]{
            1&1&0\\
            1&0&1\\
            1&-1&0\\
            1&0&-1      
            } 
            \\
            \bracketMatrixstack[r]{
            1&1&1&1\\
            1&0&-1&0\\
            0&1&0&-1
            } 
            &
            \bracketMatrixstack[r]{
            4&0&0\\
            0&2&0\\
            0&0&\phantom{-}2
            }   
    \end{aligned}
    \] 
\end{document}

enter image description here


A nicematrix attempt:

  • Wrap the aligned environment inside NiceMatrixBlock, and use option auto-columns-width.
  • Use bNiceMatrix instead of bmatrix environment, and use options R to align every cell to the right.

Note that the option auto-colums-width uses equal width for every column, hence the result may be a bit too wide for some column without

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
$\begin{NiceMatrixBlock}[auto-columns-width]
  \begin{aligned}
    & 
    \begin{bNiceMatrix}[R]
      1 & 1  & 0  \\
      1 & 0  & 1  \\
      1 & -1 & 0  \\
      1 & 0  & -1
    \end{bNiceMatrix}
    \\
    \begin{bNiceMatrix}[R]
      1 & 1 & 1  & 1  \\
      1 & 0 & -1 & 0  \\
      0 & 1 & 0  & -1
    \end{bNiceMatrix}
    &
    \begin{bNiceMatrix}[R]
      4 & 0 & 0 \\
      0 & 2 & 0 \\
      0 & 0 & 2
    \end{bNiceMatrix}
  \end{aligned}
\end{NiceMatrixBlock}$
\end{document}

This sets every column inside the block with same width, which may not be the best, but is rather automatic.

enter image description here