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 am writing my thesis, and when I do copy to LaTeX from Mathematica, it changes the equation variables and also it rearranges the structure of the original equation.

How can I override that ??

New information and further reading :

Its really annoying especially when I have to get the exact same form.


1: Mathematica code:

TeXForm[HoldForm[E^(-I k( (\[Xi]/Subscript[z, 1]+u/Subscript[z, 2]) x+ (\[Eta]/Subscript[z, 1]+v/Subscript[z, 2]) y))]]

2: How it looks in Mathematica:


3 Mathematica Output:

\exp \left(-i

4 Copy paste #3 into LaTeX, the result:

output on PDF Thanks

share|improve this question
Try HoldForm: TeXForm[HoldForm[1 + x]] – Jonathan Shock May 1 '13 at 2:30
Dint work , Could you please try on your mathematica : HoldForm[U[x, y] = Subscript[E, 0]/(4 \[Pi]) E^(I k Subscript[z, 1])/Subscript[z, 1] E^(I k/(2 Subscript[z, 1]) ((\[Xi] - x)^2 + (\[Eta] - y)^2))] – abhilash sukumari May 1 '13 at 2:41
HoldForm on the equation I wanted itself gave me rearraged one: U[x, y] = ( Subscript[E, 0] E^(I k Subscript[z, 1]) E^(( I k ((\[Xi] - x)^2 + (\[Eta] - y)^2))/( 2 Subscript[z, 1])))/((4 \[Pi]) Subscript[z, 1]) – abhilash sukumari May 1 '13 at 2:42
Try this link. – Rod May 1 '13 at 3:16
Please edit your question to include an example of the expressions you are working with, including the transformed output. – m_goldberg May 1 '13 at 3:21
up vote 6 down vote accepted

Perhaps something like this could help?

SetAttributes[copyAsLatex, HoldFirst];
copyAsLatex[sth_] := CopyToClipboard[ToString[HoldForm[sth] /.
    x_ /y_ :> Divide[x, y], TeXForm]]


 U[x, y] = 
  Subscript[E, 0]/(4 \[Pi]) E^(I k Subscript[z, 1])/
     1] E^(I k/(2 Subscript[z, 1]) ((\[Xi] - x)^2 + (\[Eta] - y)^2))]

copies the following to the clipboard

(* U(x,y)=\frac{e_0}{4 \pi } \frac{e^{i k z_1}}{z_1} e^{i \frac{k}{2 z_1} \left((\xi -x)^2+(\eta -y)^2\right)} *)
share|improve this answer
Can you explain why Subscript[E,0] gave an TeXForm of \frac{e_0} ?? Why the change from Caps to Small. Just curious ... – abhilash sukumari May 2 '13 at 2:10
@abhilashsukumari E has the built in meaning of "euler's number", the base of the natural log. In standard math that's written in lowercase – Rojo May 2 '13 at 11:36
Thanks ... That makes sense now ... – abhilash sukumari May 2 '13 at 13:27

If you want the exact same formatting as in the StandardForm output of your Mathematica session, then you could do the following:

U[x, y] = (Subscript[E, 
      0] E^(I k Subscript[z, 
         1]) E^((I k ((\[Xi] - x)^2 + (\[Eta] - y)^2))/(2 Subscript[z,
            1])))/((4 Pi) Subscript[z, 1]);

TeXForm[StandardForm[U[x, y]]]

\frac{\exp \left(\frac{i k \left((-y+\eta )^2+(-x+\xi )^2\right)}{2 z_1}+i k z_1\right) e_0}{4 \pi z_1}

Here, I added StandardForm because usually TeXForm goes via a conversion to TraditionalForm which re-arranges some terms, for example the -y + η.

This is described under "Generalizations and Extensions" in the help page for TeXForm.

share|improve this answer
If I understand correctly @abhilash sukumari wants the answer to include multiple \frac{}{} elements multiplied together, not everything collected into a single \frac{} as happens in this example. ie. something that has a/b c/d as is the form of the input` – Jonathan Shock May 1 '13 at 4:00
@JonathanShock I understood it differently. The question is explicitly about TeXForm rearranging things. What you mention already happens in StandardForm. If you're right, the question is phrased incorrectly. – Jens May 1 '13 at 4:04
I don't think it's phrased incorrectly. He may be copying as LaTeX straight from his input – Rojo May 1 '13 at 4:14
@Rojo Ah, that could be. I'll wait for clarification. – Jens May 1 '13 at 4:29
@Rojo : Yes, I am trying to get multiple fraction terms instead of self-arranging to compact single fraction. I shall edit the question with a simple Equation that has very different looks in standard and TeXForm. – abhilash sukumari May 2 '13 at 1:45

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.