If I define the following two commands:

\newcommand{\TestA}[1][]{a^{#1} aaa}

and then call it by


I get the error:

"Argument of \\TestB has an extra  }."

But $\TestB[111]$ and $\TestA[111]$ works...

Is this a bug or am I doing something wrong?

  • Welcome to TeX.SX!. When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should look like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves everyone time:)
    – user30471
    Nov 20, 2014 at 13:08

1 Answer 1


You are confusing latex with the square backets for the optional arguments. When latex sees


it thinks that the optional argument for \TestA is \TestB[111. Now it tries to evaluate this expression and gets confused because \TestB is not conforming to syntax.

To fix this you need to put brackets around the optional argument to \TestA:

  • 1
    Thanks. This workaround solves the problem. Nevertheless in my opinion I would expect Latex to behave differently...
    – mimi
    Nov 20, 2014 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .