# Question about formatting subscripts and superscripts for display

I want to display a variable with multiple subscripts (divided by commas) and a superscript surrounded by parentheses.

Namely, I want something like this:

rulesForDisplaying = { a[n_,i_,k_] -> _____________ }


where the _____ is something that will make a[n,i,k]//rulesForDisplaying show up as

$$a_{n,i}^{(k)} \ \ ,$$

where $n$,$i$, and $k$ can be anything.

I've tried doing something like Superscript[Subscript[a,n,i],k], but there's two issues: (1) I don't know how to get artifical parentheses around k and (2) the k ends up displayed far off to the right as opposed to on top of the "n,i".

I apologize if this question has been asked before, but I haven't been able to find the relevant post. I'm using Mathematica 10.1, if that's relevant.

Thanks!

rulesForDisplaying[x_, n_, j_, z_] :=
\!$$\*SubsuperscriptBox[\(x$$, $$n, j$$, $$"\<(\>" <> ToString[z] <> "\<)\>"$$]\)

rulesForDisplaying[x, n, j, z]


$x_{n,j}^{\text{(z)}}$

or....

rulesForDisplaying2[a[n_, j_, z_]] :=
\!$$\*SubsuperscriptBox[\(a$$, $$n, j$$, $$"\<(\>" <> ToString[z] <> "\<)\>"$$]\)

rulesForDisplaying2[a[n, j, z]]


$a_{n,j}^{\text{(z)}}$

• Thanks! I think that last edit did it. :) – nukeguy Sep 23 '15 at 18:51
• a little variation: Subsuperscript[a, Row[{n, j}, ","], MatrixForm[{z}]] – george2079 Sep 23 '15 at 18:57

Format automatically formats for display

Format[a[n_, i_, k_]] :=
Subsuperscript[a,
ToString[n] <> "," <> ToString[i],
"(" <> ToString[k] <> ")"]

{a[n, i, j], a[1, 2, 3]}