# Help me input a column vector

I'm trying to input an arrow vector (a column vector, see the picture) in an align environment, but it reports an error.

Can someone show me the TeX code of it in an align environment?

-
Crosspost to LaTeX Community –  Johannes_B Jan 11 '14 at 23:42

You can use bamtrix from amsmath with \vdots:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
y &= \begin{bmatrix}
x_{1} \\
x_{2} \\
\vdots \\
x_{m}
\end{bmatrix}
\end{align}
\end{document}


\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
y &= (x_{1},x_{2},\cdots, x_{N})
\begin{pmatrix}
\begin{bmatrix}
ax_{0} + bx_{1} \\
\vdots \\
ax_{n-1}+bx_{n}
\end{bmatrix} -
\begin{bmatrix}
z_{1} \\
\vdots \\
z_{n}
\end{bmatrix}
\end{pmatrix}
\end{align}
\end{document}


-
Thank you!My problem is if it's part of matrix calculation,like an arrow multiply it,how should I input? –  dream_big Jan 11 '14 at 23:45
@dream_big; Sorry I didn't follow. You mean multiply this matrix with another matrix? Can you add a picture? –  user43963 Jan 11 '14 at 23:46
okay,I'm writing it down and take a pic of it. –  dream_big Jan 11 '14 at 23:50
;i have uploaded a pic,pls have a look –  dream_big Jan 11 '14 at 23:54
@dream_big: I have updated the answer. –  user43963 Jan 12 '14 at 0:15

\documentclass[preview,border=12pt,12pt,varwidth]{standalone}% change this setting back to \documenctclass{article}!
\usepackage{amsmath}

\def\A{
\begin{bmatrix}
x_1 & x_2 & \cdots & x_N
\end{bmatrix}}

\def\B{
\begin{bmatrix}
ax_0 + bx_1 \\
ax_1 + bx_2 \\
\vdots \\
x_{N-1} + x_N
\end{bmatrix}}

\def\C{
\begin{bmatrix}
z_1 \\
z_2 \\
\vdots \\
z_N
\end{bmatrix}}

\begin{document}
\abovedisplayskip=0pt\relax% don't use this line in your production!
$$y =\A \left(\B - \C\right)$$
\end{document}


## Suggestions:

• Avoid using {} for a one-digit number (0, 1, 2, ..., 9), a Latin letter (a, b, c, ..., z), a Greek letter such as (\alpha, \beta, \gamma, ...) as a subscript (or superscript). For example, x_{2} should be written as x_2, x_{N} should be written as x_N and x_{\alpha} should be written as x_\alpha. It makes the code not only easy to read but also save more keystrokes. Note from @egreg: x_{\notin} cannot be written as x_\notin. Note from me: x_{\sin} cannot be written as x_\sin.

• For the sake of consistency, use the same bracket for column and row vectors. For example, (x_1,x_2,\cdots,x_N) should be written as \begin{bmatrix} x_1 & x_2 & \cdots & x_N\end{bmatrix}.

• If you have just one line of equation with an equation number, use equation instead of align.

• Use def or newcommand (recommended) to decompose complicated equations into several reusable parts such that the complicated equations become easy to read and the smaller parts can be reused consistently everywhere in your documents.

-
What do you mean with «A recommended solution»? I have seen that in many of your answers. –  Manuel Jan 12 '14 at 0:13
@Manuel: It can be regarded as my opening greeting. :-) –  kiss my armpit Jan 12 '14 at 0:15
I don't agree that x_N is better than x_{N}. I believe the exact opposite. –  egreg Jan 12 '14 at 0:44
@egreg That's why I was surprised about that opening greeting. Apart from being so, that phrase has a meaning, and in fact, I think I would never use it as an “opening greeting”. –  Manuel Jan 12 '14 at 15:48
@StiffJokes Most personal macros would require braces. –  egreg Jan 12 '14 at 16:40