latex

How to Write and Use a Column Vector in LaTeX

If you are a little bit familiar with mathematics, you probably know about linear algebra, which includes column vectors. That’s why LaTeX also has simple codes to write the column vectors in any technical document.

Many users may not be familiar with how to create a column vector, which sometimes results in compilation errors. In this tutorial, we will include different examples to explain the methods for writing and using a column vector in LaTeX.

How to Write and Use a Column Vector in LaTeX?

To create a column vector, you have to write a complete structure in the source code, so here is a basic example of it:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{align}
    X &= \begin{bmatrix}
           k_{1} \\
           k_{2} \\
           \vdots \\
           k_{n}
         \end{bmatrix}
  \end{align}
\end{document}

Output

In the above source code, we have used amsmath \usepackage to compile the source code correctly.

Now, let’s take another example in which we will create a mathematical expression that contains a column vector:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{align}
    X &= (a_{1},a_{2},\cdots, a_{m})
        \begin{pmatrix}
          \begin{bmatrix}
           ka_{0} + la_{1} \\          
           \vdots \\
           ka_{m-1}+ la_{m}
          \end{bmatrix} -
          \begin{bmatrix}
           b_{1} \\
           \vdots \\
           b_{m}
         \end{bmatrix}
    \end{pmatrix}
  \end{align}
\end{document}

Output

Conclusion

This is how you can quickly write and use a column vector in LaTeX. It is easy to create a column vector, but many beginners sometimes get confused between the \begin{bmatrix} and \begin{algin}. That’s why we have explained simple examples to write a mathematical expression that includes a column vector easily.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.