Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


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?

share|improve this question
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. – Nasser May 29 '14 at 23:55
The expression you give as an example in markdown is not equivalent to the expression you show in the imbedded images. – m_goldberg May 30 '14 at 0:21
@m_goldberg oops sorry. – chris May 30 '14 at 2:39
@Nasser thanks. It does partially do the job, see my edit? – chris May 30 '14 at 2:44
up vote 4 down vote accepted

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

share|improve this answer
Thanks again: inspired by your answer, it seems Map[HoldForm, exp]//TeXForm does more or less the trick. – chris May 30 '14 at 3:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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