In Latex, I always use \mathbb{something0}_{something1}^{something2}, wheres sometimes 'something1' or 'something2' can be empty. So I had the idea to create a newcommand using the \newcommand. So I tried a lot. I wanna know if is possible to create a command such that if I use \mb{R} it's print \mathbb{R}; if I use \mb[+]{R} it's print \mathbb{R}_{+}; if I use \mb[n][+]{R} it's print \mathbb{R}_{+}^{n}. Or a newcommand that do something like that.

This is one of my attempts:

\newcommand{\mb}[3][ ]{\mathbb{#3}_{#2}^{#1}}

but when I try \mb[n][+]{R} the command only print \mathbb{R}^b+.


  • Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Commented Jul 23, 2014 at 20:28

1 Answer 1


This may help you:

More than one optional argument for newcommand

For your specific example though, I usually just do the following:


And then I write


I find that much more easily readable.

You must log in to answer this question.