There are a few things going on here. Let me start with the right way to do this:
test := e_{\mu}{}^{a};
for n in test:
display(n.ex())
In order to display Cadabra expressions, it's almost always best to use display
, as print
lacks the logic to make the notebook display LaTeX expressions. The display
function ensures that many things (mathematical expressions, plots, ...) show up in the best way in the notebook.
You also need n.ex()
, not just n
, because display
does not (yet) understand the ExNode
object (which n
is). For everything it does not understand, it calls str
on it, and then you are effectively back to what you wrote. By calling n.ex()
you convert the ExNode
object n
to an Ex
object, which display
knows how to handle.
Finally: I agree it would have been useful if str(n)
produced something printable in the notebook (so that your original code would display the three expressions in non-typeset LaTeX form). Unfortunately, by default str
turns \mu
into the Unicode symbol for that character, and LaTeX doesn't understand that. This is a bug, we should turn off Unicode printing in the notebook.