# Specify newcommand to provide default argument to existing command

I have an existing command, defined within a \newenvironment:

\newcommand{\param}[3]{\textbf{##1} & \emph{##2} & ##3 \\ }


That command on its own works fine.

What I want to be able to do is to alias this command for typical use cases. The second argument to this command is a type, so I want something like:

\providecommand{\number}{}
\renewcommand{\number}[2]{\param{##1}{number}{##2}}


However, this gives the error: Argument of \number has an extra }.

This error appears even if the \number command is never used.

What would the cause of this be?

-
The idea is fine per se, but \number is a TeX primitive, so redefining it is probably causing an issue with a place where the original version is expected. – Joseph Wright Jan 17 at 6:23
Aha, that appears to be it. I realised that \number was an existing command, but I thought that if I redefined it within the \newenvironment, it wouldn't cause any problems (as the scope would be limited). It seems I was wrong on that! If you post that as an answer, I'll accept you. – sapi Jan 17 at 6:29

As Joseph said, redefining \number is a bad idea, It's particularly self referential here as \newcommand (and \providecommand etc) all use \number to process the [2] optional argument that specifies how many arguments the command has. This normalises away any space and TeX constructs that expand to a number and exposes the literal digit that is needed to construct the #1#2 primitive TeX \def syntax.

\long \def \@yargdef #1#2#3{%
\ifx#2\tw@
\def\reserved@b##11{[####1]}%
\else
\let\reserved@b\@gobble
\fi
\expandafter
\@yargd@f \expandafter{\number #3}#1%
%%%%%%%
%%%%%%%
}

-