7
$\begingroup$

According to the documentation, TeXForm uses the TraditionalForm formatting to generate the TeX code.

However, for some cases, this is not ideal. For example, it would be better to display the Feynman slash $\sum_\mu \gamma_\mu p^\mu$ as

CenterDot[γ, p]$\equiv \gamma\cdot p$ in TraditionalForm in the Mathematica front end,

but as \slashed{p}$\equiv p\!\!/\,\,$ in TeXForm (using the slashed package).

How do I tell TeXForm that each time CenterDot[γ, p_] is encountered in an expression, it should be formatted \slashed{p}?

I'm looking for a back-end solution, so that TeXForm on an input or output would automatically give the correct code. Solutions requiring more than the minimal TeXForm to generate $\TeX$ code will not be accepted.

$\endgroup$

1 Answer 1

6
$\begingroup$

Using this answer by @jkuczm, the following works for me in version 10.3:

slashed /: MakeBoxes[slashed[x_], TraditionalForm | StandardForm] := 
 RowBox[{"\[Gamma]\[CenterDot]", ToBoxes[x]}]

System`Convert`TeXFormDump`maketex[
  RowBox[{"\[Gamma]\[CenterDot]", a_}]] := 
 "\\slashed{" <> System`Convert`TeXFormDump`MakeTeX[a] <> "}"

CenterDot[\[Gamma], x_] := slashed[x]

I define an auxiliary function slashed and give it different formatting rules for the different forms. The I define CenterDot for the special case where the first argument is γ, to be interpreted as slashed. Here is a screen shot of the formatting:

screen shot

$\endgroup$
1
  • $\begingroup$ This is a perfect solution. As a note to myself (and others), the argument of System`Convert`TeXFormDump`maketex should be a box structure in TraditionalForm. $\endgroup$
    – QuantumDot
    Commented Mar 16, 2016 at 15:00

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.