[Tex/LaTex] Arguments of custom commands as comma separated list

macros

Consider the follwing command:

 \newcommand{\vektor}[3]{\left(\negthinspace\begin{smallmatrix}#1\\#2\\#3    \end{rsmallmatrix}
 \right)}

I can use it like

$\vektor{1}{2}{3}$

Now my question is whether it is possible to redefine the command such that the arguments are a comma separated list, such that I could write:

$\vektor{1,2,3}$

Best Answer

It's easy to do this sort of thing using \def, if you don't mind putting the argument inside delimiters that are not braces.

\documentclass{minimal}
\usepackage{amsmath}
\def\vektor(#1,#2,#3) {\left(\negthinspace\begin{smallmatrix}#1\\#2\\#3 \end{smallmatrix} \right)}
\begin{document}
\[ \vektor(a,b,c) \]
\end{document}

Obviously, the above would go horribly wrong if you replace the parentheses with braces.

EDIT

See Ryan Reich's answer (or Aditya's comment) for a neat modification that allows you to use braces.