Vertical Alignment – How to Vertically Align Tops of Matrices in an Equation

matricesvertical alignment

The following matrix equation looks great:

\begin{align*}
\overset{A}{\left[\begin{matrix}t_{1}&1\\ 
\vdots&\vdots\\
t_{n}&1
\end{matrix}\right]}
\overset{x}{\left[\begin{matrix}
x_{1}\\x_{2}
\end{matrix}\right]}
&=
\overset{b}{\left[\begin{matrix}
b_{1}\\ \vdots \\ b_{n}
\end{matrix}\right]}
\end{align*}

Except I am accustomed to having the tops of my matrices aligned when I write on scratch paper. How can I accomplish this in LaTeX?

Best Answer

A note before, amsmath provides special *matrix environments:

  • pmatrix for ( · )
  • bmatrix for [ · ]
  • Bmatrix for { · }
  • vmatrix for | · |
  • Vmatrix for || · ||

Solution 1

I used the \vphantom macro that resizes the box inside the \overset to same height like the other parts.

Code

\documentclass{article}
\usepackage{amsmath}
\newcommand*\biggestpart{}
\begin{document}
\renewcommand*\biggestpart{
  \begin{bmatrix}
    t_1    & 1 \\
    \vdots & \vdots \\
    t_n    & 1
  \end{bmatrix}
}
\begin{align*}
\overset{A}{\biggestpart}
\overset{x}{
  \vphantom{\biggestpart}
  \begin{bmatrix}
    x_1 \\ x_2
  \end{bmatrix}
}
&=
\overset{b}{
  \begin{bmatrix}
    b_1 \\ \vdots \\ b_n
  \end{bmatrix}
}
\end{align*}
\end{document}

Output

enter image description here

Solution 2

As the second row in the bigger matrices are not of the same height of x_2 the \vphantom command is used again (try it without to see the effect or replace \vdots with “normal” math stuff like x_0).

Code

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\overset{A}{
  \begin{bmatrix}
    t_1    & 1 \\
    \vdots & \vdots \\
    t_n    & 1
  \end{bmatrix}}
\overset{x}{
\begin{array}{@{}c@{}}{
  \begin{bmatrix}
    x_1 \\ x_2 \vphantom{\vdots}
  \end{bmatrix}}\\
  \\
  \end{array}
}
&=
\overset{b}{
  \begin{bmatrix}
    b_1 \\ \vdots \\ b_n
  \end{bmatrix}
}
\end{align*}
\end{document}

Output

enter image description here