2

This is the state of affairs:

state of affairs

The goal is to horizontally center the symbols over their expressions within an equation environment. So A is centered over the first matrix, x centered over the first vector and b centered over the final vector.

MWE:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

  \begin{equation}
    \begin{split}
      %
      {\bf{A}} x & = b \\
      %
       \left[
       \begin{array}{cc}
          1 & 0 \\ 0 & 1 \\
       \end{array}
       \right]
       %
       \left[
         \begin{array}{c}
            x_1 \\ x_2
         \end{array}
       \right] &=
       %
       \left[
         \begin{array}{c}
            b_1 \\ b_2
         \end{array}
       \right]
       %
    \end{split}
  \end{equation}

\end{document}

These posts do not seem to offer readily a solution:

Complicated alignment within multiline equation

Aligning Multiline Matrix Equations

Aligning equations with text with alignat

Difference between align and alignat environments

TeXShop 3.58, distribution TeXLive - 2015

2 Answers 2

4

With array you can obtain the following:

enter image description here

\documentclass{article}
\usepackage{amsmath}
    
\begin{document}
\begin{equation}\arraycolsep=1pt
    \begin{array}{cccc}
\mathbf{A}      &  \mathbf{x}       & = &   \mathbf{b}  \\
    \begin{bmatrix}
    1 & 0 \\ 0 & 1 \\
    \end{bmatrix}   &   \begin{bmatrix}
                        x_1 \\ x_2
                        \end{bmatrix}   & = &   \begin{bmatrix}
                                                b_1 \\ b_2
                                                \end{bmatrix}
    \end{array}
\end{equation}
\end{document}

addendum: After seve years ...

Considered is @Mico comment below. Typographical more correct result you will get if in matrices be restored default \arraycolsep value (6pt). This can be done with adding

\AtBeginEnvironment{bmatrix}{\arraycolsep=6pt}

in document preamble. If you still have an older LaTeX installation, you also need to load \etoolbox package:

\documentclass{article}
\usepackage{mathtools}

%\usepackage{etoolbox} % activate if you have an older LaTeX instalation
\AtBeginEnvironment{bmatrix}{\arraycolsep=6pt}

% for show just the equation, don't use in the real document  ...
\usepackage[active,displaymath,tightpage]{preview}
\setlength\PreviewBorder{1em}

\begin{document}

\begin{equation}\arraycolsep=1pt
    \begin{array}{cccc}
\mathbf{A}      &   \mathbf{x}       & = &   \mathbf{b}  \\
\begin{bmatrix}
1 & 0 \\ 0 & 1 \\
\end{bmatrix}   &   \begin{bmatrix}
                    x_1 \\ x_2
                    \end{bmatrix}   & = &   \begin{bmatrix}
                                            b_1 \\ b_2
                                            \end{bmatrix}
    \end{array}
\end{equation}

\end{document}

enter image description here

3
  • +1. I think it would add a nice touch to locally restore the default value of \arraycolsep for the first of the three bmatrix environments.
    – Mico
    Feb 20, 2022 at 7:27
  • 1
    @Mico, you are right. For example, it can be done ba adding \AtBeginEnvironment{bmatrix}{\arraycolsep=6pt} in document preamble. Will add to answer ASAP.
    – Zarko
    Feb 20, 2022 at 7:33
  • 1
    @Mico, now is done.
    – Zarko
    Feb 20, 2022 at 8:09
1

The obvious choice is array, but with some tricks to avoid guessing the spaces.

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{array}

\newenvironment{lsarray}[1][c]% ls for 'linear system'
 {\begin{array}[#1]{@{} c @{} c @{} >{{}}c<{{}} @{} c @{}}}
 {\end{array}}

\begin{document}

Centered equation number:
\begin{equation}
\begin{lsarray}
  \mathbf{A} & \mathbf{x} & = & \mathbf{b} \\
  \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} &
  \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} &
  = &
  \begin{bmatrix} b_1 \\ b_2 \end{bmatrix}
\end{lsarray}
\end{equation}

Bottom equation number:
\begin{equation}
\begin{lsarray}[b]
  \mathbf{A} & \mathbf{x} & = & \mathbf{b} \\
  \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} &
  \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} &
  = &
  \begin{bmatrix} b_1 \\ b_2 \end{bmatrix}
\end{lsarray}
\end{equation}

\end{document}

The twocolumn option is used just to make a less wide picture, in order to better see the equation number placement in the two cases.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .