You have \newcommand{\Ma}[1][]{...
. The last pair of brackets mean that the macro has one optional argument, which by default is empty. #1
refers to this optional argument. To use an optional argument, you need \Ma[a]
. Because no [
is seen, the {a}
is not read as an optional argument, and so is just typeset as normal. Use \newcommand{\Ma}[1]{...
, or see example below.
Following up on Ulrike's comment, some links about xspace
and \ensuremath
:
And a complete example, with two possible macro definitions.
\documentclass{article}
\newcommand{\Ma}[1]{M_{1}^{#1}}
\newcommand{\Mb}[2][1]{M_{#1}^{#2}}
\begin{document}
$\Ma{a}, \Mb{b} \Mb[]{c} \Mb[2]{d}$.
\end{document}
[a]
as input. xspace is quite useless here and I wouldn't use \ensuremath either.