4

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

  • 5
    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
5

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.

| improve this answer | |
1

There is also \parenVectorstack:

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

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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