# Array within Align*

LaTeX fresh beginner here. Using TexStudio. In the second row of an equation array (using align*), I am trying to multiply a row vector by a column vector, using the array command. Apparently the array within the align* is causing a problem. The LaTeX won't even compile. Here is my document:

\documentclass[final]{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\newcommand{\E}{\mathbb{E}}
\begin{document}

\section{Introduction} \label{intro}
Using the assumption that $\E(\bm{X}_t u_t)=0$, its sample mean form yields:

\begin{align*}
\frac{1}{n} \sum_{t=1}^{n} \bm{X}_t u_t &= \frac{1}{n}(X_{1i}u_1+X_{2i}u_2+\dotsb+X_{ni}u_n) \\
&= \frac{1}{n}
\left[
\begin{array}{cccc}
X_{1i} & X_{2i} & \cdots & x_{ni}
\end{array}
\right]
\left[
\begin{array}{c}
u_1 \\ \u_2 \\ \vdots \\ \u_k
\end{array}
\right] \\
&= \frac{1}{n} \bm{x}_i^T \bm{u} =0 \\
\end{align*}

\end{document}


So I want all of the equals to line up. (Unless it's possible for the last one to make the final "=0" display to the right of everything?) But right now I'm mostly worried about the problems with my code and why it won't even compile.

• Welcome to TeX.SX! As a side note, you could use \begin{bmatrix} ... \end{bmatrix} instead of \left[\begin{array}{cccc} ... \end{bmatrix}\right]. – Torbjørn T. Mar 15 '14 at 22:41
• Don't leave a blank line before align* or any other display environment. For the =0, setting it at the far right will make it hang from nowhere. Either leave it there or in a new line. – egreg Mar 15 '14 at 22:43
• Thank you for the welcome and advice! Your suggestion to use "bmatrix" was very helpful -- it makes my code a lot shorter and simpler. Also, thanks for the "=0" tip. – Mathemanic Mar 15 '14 at 22:57

Well, I don't understand what's incorrect with your code (except perhaps that \\ is used to indicate a new line of alignment, and also a new line in your matrices). Anyway, simplifying you code with the bmatrix environment works fine:

    \documentclass[final]{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\newcommand{\E}{\mathbb{E}}
\begin{document}

\section{Introduction} \label{intro}
Using the assumption that $\E(\bm{X}_t u_t)=0$, its sample mean form yields:

\begin{align*}
\frac{1}{n} \sum_{t=1}^{n} \bm{X}_t u_t &= \frac{1}{n}(X_{1i}u_1+X_{2i}u_2+\dotsb+X_{ni}u_n) \\
&= \frac{1}{n}
\begin{bmatrix}%
X_{1i} & X_{2i} & \cdots & X_{ni}
\end{bmatrix}
\begin{bmatrix}
u_1 \\u _2\\ \vdots \\ u_n
\end{bmatrix}
\\
&= \frac{1}{n} \bm{x}_i^T \bm{u} =0 \\
\end{align*}

\end{document}


• As I said in a comment to the question, there shouldn't be a blank line just before align*. – egreg Mar 15 '14 at 23:27
• @egreg: Once more, I was checkin my answer while you were writing a comment, and I didn't verify before posting… – Bernard Mar 15 '14 at 23:43

Nothing to do with nesting array you have \u instead if u twice in the second array. Change those to u and it all works.

• That's it - I can't believe I didn't see that. I imagine as I get more practice working with and seeing the LaTeX code, I'll be able to recognize and spot errors better. Thank you! – Mathemanic Mar 15 '14 at 22:55