Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Context

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

Example

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.

Question

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?

EDIT

Following the suggestion of @Nasser, I tried

Mathematica graphics

So it does not really preserve the original expression?

share|improve this question
1  
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 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 at 0:21
    
@m_goldberg oops sorry. –  chris May 30 at 2:39
    
@Nasser thanks. It does partially do the job, see my edit? –  chris May 30 at 2:44
add comment

1 Answer 1

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:

\documentclass[12pt,notitlepage]{article}%
\begin{document}
    $\left(\left(r^2-3\right) I_0\left(\frac{r^2}{8}\right){}^2+15 I_1
\left(\frac{r^2}{8}\right){}^2-\frac{\left(r^4+16
       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}}$
    \end{document}

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 at 3:39
add comment

Your Answer

 
discard

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.