Copy xAct expression to LaTeX

6

3

How can I copy an xAct expression to LaTex? Using the usual command TeXForm[] gives the xAct structure, I would like to get the printed form. For example

$$ \text{TeXForm}[\nabla_a\phi\nabla^a\phi] $$

gives

\text{CD}(-a)(p()) \text{CD}(-a)(p())

which is how I defined my tensors.

marRrR

Posted 2016-05-03T13:36:33.507

Reputation: 125

1Thanks for the example, I've never used xAct before, but I have it installed, how would I go about having $\nabla_a\phi\nabla^a\phi$ defined in the first place? Which subpackage(s) do I need to load, and what commands do I need to enter in order to have it as an object I can try to act on? – Jason B. – 2016-05-03T14:13:51.627

The basic commands you need to defined this expression are: $\$ << xActxTensor 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[]) – marRrR – 2016-05-03T14:57:05.630

Answers

7

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[])

enter image description here

Let's look at all the various forms there are of this expression,

Through[{TraditionalForm, TeXForm, InputForm, FullForm, StandardForm}[test]]

enter image description here

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) $$

Jason B.

Posted 2016-05-03T13:36:33.507

Reputation: 58 546