I'm trying to convert tensorial expressions from xAct to LaTeX format using the TeXForm command. This seems to work fine when using covariant derivatives (As in Copy xAct expression to LaTeX). However, this seems to change when employing curvature invariants such as $R_{a}^{\ \ b}{}_c^{\ \ d}R^{a}_{\ \ b}{}^c_{\ \ d}$. In this case, evaluating $$\texttt{TeXForm@StandardForm@RiemannCD[-a, b, -c, d] RiemannCD[a, -c, b, -d]}$$ yields

enter image description here

Do you know how to avoid the array command and produce a similar output as in the previous link?


1 Answer 1


xAct contains a full package dedicated to converting tensor expressions into LaTeX, called TexAct, and I'd recommend using that instead of the general TeXForm.

For example, in your case:

<< xAct`xTensor`
<< xAct`TexAct`

DefManifold[M, 4, {a, b, c, d}]
DefMetric[-1, g[-a, -b], CD]

expr = RiemannCD[-a, -b, -c, d] RiemannCD[a, c, b, -d];

In[]:= TexPrint[%]
Out[]= "R[\\nabla]_{abc}{}^{d} R[\\nabla]^{acb}{}_{d}"

If you want to change the name of the Riemann tensors use

PrintAs[RiemannCD] ^= "R";

In[]:= TexPrint[expr]
Out[]= "R_{abc}{}^{d} R^{acb}{}_{d}"

If your expressions are very large then look at the documentation of TexBreak on how to break the single-line TeX output into several lines. Note also the commands TexPort to send the result to a file and TexView to visualize the output.

  • $\begingroup$ Thanks a lot Jose. I was not aware of the existence of TexAct and it is useful for all my purposes. $\endgroup$ Dec 10, 2020 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.