Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
4  
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 '13 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 '13 at 6:29

1 Answer 1

up vote 5 down vote accepted

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%
                           %%%%%%%
                           %%%%%%%
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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