# providecommand for column vector

I'm trying to provide a command for a column vector. I defined this in the header:

\providecommand{\vector}[3]{\ensuremath{\left(
\begin{matrix}
#1 \\
#2 \\
#3
\end{matrix}
\right)}}


and then in the document:

\vector{-\sin\varphi}{\cos\varphi}{0}


but I get an error message:

Use of \vector doesn't match its definition.


Any ideas?

thanks

• Welcome to TeX.SX! The LaTeX kernel already defines \vector, so your \providecommand does nothing. Choose a different name, say \cvector. – egreg Jan 30 '15 at 15:58

With \providecommand{\vector}[3]{...} you are saying

Dear LaTeX, if no command \vector is defined, please define it as I'd like to, otherwise do nothing and keep the previous definition

With \newcommand{\vector}[3]{...} you are saying

Dear LaTeX, if no command \vector is defined, please define it as I'd like to, otherwise tell me by raising an error

With \renewcommand{\vector}[3]{...} you are saying

Dear LaTeX, if a command \vector is defined, please redefine it as I'd like to, otherwise tell me by raising an error

For \vector we are in the situation where the command is already defined. So \providecommand has no effect and upon usage you either get an error or funny output. You might decide to go for the \renewcommand road, but this would be wrong: the kernel \vector command is used in picture mode and some package you load could use it: disaster would ensue.

Use a different name, like \cvector, instead.

There is also \parenVectorstack:

\documentclass{article}
\usepackage{stackengine}
\stackMath
\begin{document}
$\parenVectorstack{{-\sin\varphi} {\cos\varphi} {0}}$
\end{document}