[Tex/LaTex] Creating a matrix with column or row vectors as arguments

matricesvector

At times it's convenient to write a matrix in terms of it's row or column component vectors instead of explicitly giving each particular scalar entry. I'm basically talking about this:

enter image description here

I did some research, but I couldn't find any way to express a matrix in this way.

Best Answer

Check this:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

% Vertically stacked
\[
\begin{bmatrix}
    \vert & \vert \\
    v_1   & v_2   \\
    \vert & \vert
\end{bmatrix}
\]

% Horizontally stacked
\[
\begin{bmatrix}
    \text{---} & v_1 & \text{---} \\
    \text{---} & v_2 & \text{---}
\end{bmatrix}
\]

\end{document}

enter image description here

The white space in the horizontal matrix can be reduced ad-hoc, using \hspace{}. For example:

% Horizontally stacked
\[
\begin{bmatrix}
    \text{---} \hspace{-0.2cm} & v_1 & \hspace{-0.2cm} \text{---} \\
    \text{---} \hspace{-0.2cm} & v_2 & \hspace{-0.2cm} \text{---}
\end{bmatrix}
\]

Producing:

enter image description here