7

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?

6

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

3

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

enter image description here

\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}{=}}.

1

This is janky but I wanted something dead simple so I just wrapped a \raisebox{0.5em}{$ [matrix goes here] $} around the matrix that was too low and adjusted the distance until it looked ok.

Note, \raisebox seems to put you back into text mode so you have to wrap the matrix in $ $.

Before:

enter image description here

\begin{align*}
x^T x:  
\begin{bmatrix} 
x_1 \\
x_2 \\
x_3
\end{bmatrix}
\begin{bmatrix} 
x_1 & x_2 & x_3\\
\end{bmatrix}
\end{align*}

After:

enter image description here

\begin{align*}
    x^T x:  
    \begin{bmatrix} 
    x_1 \\
    x_2 \\
    x_3
    \end{bmatrix}
    \raisebox{1.15em}{$
    \begin{bmatrix} 
    x_1 & x_2 & x_3\\
    \end{bmatrix}
    $}
\end{align*}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.