if

何度も\mathbf{x}^{(i)}とか打つのが面倒だったので、newcommandすることにしたわけです。

\newcommand\Bx[1][]{\if#1{\mathbf{x}^{(#1)}}\else{\mathbf{x}}\fi}

なんかうまくいかない。
要件としては、

  • "\mathbf{x}"だけのときもある
  • 肩に乗せるのは(i)だったり(j)だったり色々変わる

ということなので、引数の数を1、デフォルト値を空欄にしてみたのだが……
\ifの判断基準がキモか。ということでリファレンス↓を見てみた。
TeX: Reference and Examples by David Bausum

The \if condition is true if the character codes of the two tokens are the same.

TeX: Reference and Examples by David Bausum

あ、なるほど。あまりにもJavascript脳過ぎた。どちらかというとシェルスクリプトの方に近いのかー。
つまり、こうですね。

\newcommand\Bx[1][-]{\mathbf{x}\if-#1\else^{(#1)}\fi}

うまくいった。