6

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.

Thanks for your help.

3
  • 2
    Welcome to TeX.SX! As a side note, you could use \begin{bmatrix} ... \end{bmatrix} instead of \left[\begin{array}{cccc} ... \end{bmatrix}\right]. Commented Mar 15, 2014 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
    Commented Mar 15, 2014 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. Commented Mar 15, 2014 at 22:57

2 Answers 2

3

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} 

enter image description here

2
  • As I said in a comment to the question, there shouldn't be a blank line just before align*.
    – egreg
    Commented Mar 15, 2014 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
    Commented Mar 15, 2014 at 23:43
5

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.

1
  • 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! Commented Mar 15, 2014 at 22:55

You must log in to answer this question.

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