# Vertically align the tops of matrices in an equation

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?

-

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}


# 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

-
That's it exactly! Thank you. – Roci Oct 17 '12 at 15:45

Here is a sans-amsmath version of Qrrbrbirlbel's answer:

\documentclass{article}
\newcommand{\matlabel}[2]{% \matlabel{<label>}{<stuff>}
\begin{array}{@{}c@{}} \mbox{\small$#1$} \\ #2 \end{array}
}
\begin{document}
$\matlabel{A}{\left[\begin{array}{@{}cc@{}} t_1 & 1 \\ \vdots & \vdots \\ t_n & 1 \end{array}\right]} \matlabel{x}{\left[\begin{array}{@{}c@{}} x_1 \\ \vphantom\vdots x_2 \\ \end{array}\right] \\ \mathstrut}\mathrel{\raisebox{-.5\normalbaselineskip}{=}} \matlabel{b}{\left[\begin{array}{@{}c@{}} b_1 \\ \vdots \\ b_n \end{array}\right]}$
\end{document}


The only major difference is the setting of the matrix label as an element in an "vertical array", rather than an "upper limit in a math operator." As a consequence, the vertical alignment with respect to the mathematical axis has to be adjusted... using \mathrel{\raisebox{-.5\normalbaselineskip}{=}}.

-