I'll try to be clear because this is not what I am looking for.

What I'm trying to do is to define a new command that takes one argument but has a different behaviour whether that argument is or is not specified.

Here's what I have so far :


I want to be able to get :

  • nk if I enter \Nk
  • ni if I enter \Nk{i}

For now, with that second option I just get nik.

So here's my question : how can I get that behaviour I want ?

Thanks a lot.

  • 2
    Use square brackets: $\Nk[i]$ in the invocation. Square brackets are used for optional arguments, which is the way you have defined \Nk. Commented Feb 23, 2016 at 14:08

1 Answer 1


The rule of \newcommand is that optional arguments are provided in square brackets [] and mandatory arguments are provided in curly braces {}.

It is a newbie mistake to forget it, but it can be frustrating to find when it happens.

    $N_k$ if I enter $\Nk$\par
    $N_i$ if I enter $\Nk[i]$\par
    but not $\Nk{i}$.

enter image description here

You must log in to answer this question.

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