Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

enter image description hereenter image description here

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?

share|improve this question
    
Crosspost to LaTeX Community –  Johannes_B Jan 11 at 23:42
add comment

2 Answers

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}

enter image description here

Answering to the comment:

\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}

enter image description here

share|improve this answer
    
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 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 at 23:46
    
okay,I'm writing it down and take a pic of it. –  dream_big Jan 11 at 23:50
    
;i have uploaded a pic,pls have a look –  dream_big Jan 11 at 23:54
    
@dream_big: I have updated the answer. –  user43963 Jan 12 at 0:15
show 9 more comments

A recommended solution. Adapt it to suit your need.

\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!
\begin{equation}
y =\A \left(\B - \C\right)
\end{equation}
\end{document}

enter image description here

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.

share|improve this answer
1  
What do you mean with «A recommended solution»? I have seen that in many of your answers. –  Manuel Jan 12 at 0:13
1  
@Manuel: It can be regarded as my opening greeting. :-) –  Fifa Earth Cup 2014 Jan 12 at 0:15
2  
I don't agree that x_N is better than x_{N}. I believe the exact opposite. –  egreg Jan 12 at 0:44
1  
@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 at 15:48
2  
@StiffJokes Most personal macros would require braces. –  egreg Jan 12 at 16:40
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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