This imports the package and defines the variables,
<< xAct`xTensor`;
DefManifold[M4, 4, {a, b, c, d, e, f, g, h, i, j, k, l}] ;
DefMetric[-1, metric[-a, -b], CD, PrintAs -> "g"];
DefTensor[p[], M4, PrintAs -> "ϕ"];
This is your expression,
test = (CD[-a]@p[] CD[a]@p[])
Let's look at all the various forms there are of this expression,
Through[{TraditionalForm, TeXForm, InputForm, FullForm, StandardForm}[test]]
It seems that all forms except StandardForm
see test
as CD[-a][p[]]CD[a][p[]]
So we need to apply StandardForm
and then TeXForm
:
TeXForm@StandardForm@test
(* \left(\triangledown _a\phi
\right) \left(\triangledown
^a\phi \right) *)
Or, evaluated in $\TeX$,
$$\left(\triangledown _a\phi
\right) \left(\triangledown
^a\phi \right) $$
xTensor
DefManifold[M4, 4, {a, b, c, d, e, f, g, h, i, j, k, l}] DefMetric[-1, metric[-a, -b], CD, PrintAs -> "g"] %CD here refers to the covariant derivative% DefTensor[p[], M4, PrintAs -> "[phi]"] $p is the scalar field% and the expression above will be (CD[-a]@p[] CD[a]@p[]) $\endgroup$