[Tex/LaTex] How to make a newcommand producing a matrix

macrosmatrices

I would like to do something like this

\newcommand{\pmat}[1][2][3][4]{\begin{pmatrix} #1 & #2 \\ #3 & #4\end{pmatrix}}

But this produces the error

ERROR: LaTeX Error: Missing \begin{document}.
...                                              
l.42 \newcommand{\pmat}[1][2][3
                               ][4]{\begin{pmatrix} #1 & #2 \\ #3 & #4\end{p..

How do I create a newcommand \pmat such that \pmat{1}{2}{3}{4} produces \begin{pmatrix} 1 & 2 \\ 3 & 4\end{pmatrix}?

Thanks,
Thomas

Best Answer

It's because the proper syntax is

\newcommand{\pmat}[4]{\begin{pmatrix} #1 & #2 \\ #3 & #4\end{pmatrix}}

The argument between the brackets is the number of arguments, not the argument's name.