I would like to use the Mathematica front end to pre-process expressions before exporting them to LateX, for the sake of readability.


Say I have this expression

   (16*((-3 + r^2)*BesselI[0, r^2/8]^2 - ((-48 + 16*r^2 + r^4)*BesselI[0, r^2/8]*
   BesselI[1, r^2/8])/r^2 + 
   15*BesselI[1, r^2/8]^2)*Cos[2*\[Theta]])/(3*Sqrt[3]*E^(r^2/4))

which looks like this in Mathematica

Mathematica graphics

Once I edit it by hand within Mathematica, it might look like this: (notice that its more publishable in that form)

Mathematica graphics

(This is a great feature of the Front-End by the way!).

If I then select the expression and choose the export to latex menu, Mathematica exports the original (unedited) equation.


How do I tell Mathematica to mind its own business and export to LaTeX the result of my edit, not its re-processing of it?


Following the suggestion of @Nasser, I tried

Mathematica graphics

So it does not really preserve the original expression?

  • 1
    $\begingroup$ Try applying HoldForm[expr] when exporting. You might have to use HoldForm in more than one subpart of the expression if you want complete control. Hard to test it since your final expression is not posted in M code. $\endgroup$
    – Nasser
    May 29, 2014 at 23:55
  • $\begingroup$ The expression you give as an example in markdown is not equivalent to the expression you show in the imbedded images. $\endgroup$
    – m_goldberg
    May 30, 2014 at 0:21
  • $\begingroup$ @m_goldberg oops sorry. $\endgroup$
    – chris
    May 30, 2014 at 2:39
  • $\begingroup$ @Nasser thanks. It does partially do the job, see my edit? $\endgroup$
    – chris
    May 30, 2014 at 2:44

1 Answer 1


For the notebook interface, you can use HoldForm[] like this

expr2 = HoldForm[16 E^(-(r^2/4)) cos (2 \[Theta]) /(3 Sqrt[3])];
expr3 = HoldForm[((r^2 - 3) BesselI[0,r^2/8]^2 + 15 BesselI[1,r^2/8]^2 - 
        ((r^4 + 16 r^2 - 48) BesselI[1,r^2/8] BesselI[0,r^2/8])/r^2)];
TraditionalForm[expr2 expr3]

which gives

Mathematica graphics

Which is what you wanted. Now, for Latex export

TeXForm[expr2 expr3]

which gives the tex expression. I copied this to my texlive box and run latex on it:

$\left(\left(r^2-3\right) I_0\left(\frac{r^2}{8}\right){}^2+15 I_1
   r^2-48\right) I_1\left(\frac{r^2}{8}\right) I_0\left(\frac{r^2}{8}\right)}
{r^2}\right) \frac{16 e^{-\frac{r^2}{4}}
   \cos  (2 \theta )}{3 \sqrt{3}}$

and here is the pdf file result

Mathematica graphics

  • $\begingroup$ Thanks again: inspired by your answer, it seems Map[HoldForm, exp]//TeXForm does more or less the trick. $\endgroup$
    – chris
    May 30, 2014 at 3:39

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.