# How to print parentheses?

I have obtained a formula in Mathematica and I want to transfer it to Microsoft Word so I did this:

ff = (-2 a17 denP[re] + b17 Sqrt[denE[re]] denP[re]^(3/2))/(
2 (a17 - b17 Sqrt[denE[re]] Sqrt[denP[re]] +
c171 denE[re] denP[re])^2);
nn = ff /. {denE[re] ->
"\!$$\*SubscriptBox[\(\[Rho]$$, \
$$e$$]\)(\!$$\*SubscriptBox[\(r$$, $$e$$]\))",
denP[re] ->
"\!$$\*SubscriptBox[\(\[Rho]$$, \
$$p$$]\)(\!$$\*SubscriptBox[\(r$$, $$e$$]\))",
a17 -> Subscript[a, 17], b17 -> Subscript[b, 17],
c171 -> Subscript[c, 171]} // TraditionalForm


but when I copy and paste it in Word, "" are present on the other hand if I remove "" in nn Mathematica doesn't print them. Any idea?

• I deleted my answer. You can't add explicit ( ) using strings. Ofcourse they will show as strings in word. Better to not do this and leave it as is. That is the right way. But if insist on having () around each term, may be there is a way that someone could find for you. Apr 25 at 6:42
• Thanks but I have a lot long formulas which I apply such a procedure to them, so finding a efficient method will help me so much. Apr 25 at 7:02
• If you right click and choose Copy As > LaTeX, it seems to give an accurate LaTeX expression, without ". Can you then put LaTeX in a Word equation? Not sure how Word works, so not sure how feasible this is. Apr 25 at 7:04
• @thorimur I tried this, but Word has problem with showing LaTex. At the moment I copy and paste the code which includes "" and then remove them using "Find and Replace' in Word. Apr 25 at 7:06
• Hmm, what version of word are you using? It seems that Word does support LaTeX input in the equation editor, you might just have to fiddle with it a bit. If you get LaTeX working in Word, try using TeXForm instead of the whole {TraditionalForm then Copy As > ...} routine; it'll be quicker, especially if combined with CopyToClipboard which will copy the output directly upon evaluating! :) Apr 25 at 7:15

ClearAll["Global*"]

Format[re] := Subscript[r, e]
Format[a17] := Subscript[a, 17]
Format[b17] := Subscript[b, 17]
Format[c171] := Subscript[c, 171]
Format[denE] := Subscript[ρ, e]
Format[denP] := Subscript[ρ, p]

(ff = (-2 a17 denP[re] +
b17 Sqrt[
denE[re]] denP[re]^(3/2))/(2 (a17 -
b17 Sqrt[denE[re]] Sqrt[denP[re]] +


Edit | Copy As | MathML then paste into Word

This would be simplified a little if you used indexed variables such as a[17], b[17], c[171], r[e] instead of a17, b17, c171, re. Then you could use

ClearAll["Global*"]

(Format[#[n_]] := Subscript[#, n]) & /@ {a, b, c, r};
Format[denE] := Subscript[ρ, e]
Format[denP] := Subscript[ρ, p]

(ff = (-2 a[17] denP[r[e]] +
b[17] Sqrt[
denE[r[e]]] denP[r[e]]^(3/2))/(2 (a[17] -
b[17] Sqrt[denE[r[e]]] Sqrt[denP[r[e]]] +


Update:

If you are running Office 365 version 1707 or later, the Equation Editor allows you to convert LaTex into the native format. See the first part of this answer.

I have old word (2010) so I can't test the above. My word equation editor will not accept inserting raw latex in it.

But if you have newer version of word, you can convert the modified expression, after you adding those explicit "()" around the terms, to latex using TeXForm (which will keep the parentheses (surprise)), as mentioned in comments above by thorimur.

Then copy the raw latex into Word equation editor. It should work.

Alternative is to use copy as bitmap:

To do that, select the output from Mathematica using the mouse, then copy/paste as bitmap into word.

I would not recommend doing all of this myself. Output does not look best. Using bitmaps for math is not good. Using Word itself for math is not good.

Best solution is to throw away Word. Generate pure Latex from Mathematica, and use a Latex compiler to generate the PDF. That will produce best output. A professional looking document. But if insist on using Word, the above should do it.

Just remove the "" from the code you used, then it works. Where did the "" stuff come from? If you add "" then it will show up in word ofcourse.

ff = (-2 a17 denP[re] +
b17 Sqrt[
denE[re]] denP[re]^(3/2))/(2 (a17 -
b17 Sqrt[denE[re]] Sqrt[denP[re]] + c171 denE[re] denP[re])^2);
nn = ff /. {denE[
re] -> \!$$\*SubscriptBox[\(\[Rho]$$, $$e$$]\) \
(\!$$\*SubscriptBox[\(r$$, $$e$$]\)),
denP[re] -> \!$$\*SubscriptBox[\(\[Rho]$$, $$p$$]\) \
(\!$$\*SubscriptBox[\(r$$, $$e$$]\)), a17 -> Subscript[a, 17],
b17 -> Subscript[b, 17], c171 -> Subscript[c, 171]} //

• Thanks but this is not true! I want to get \rho_e (r_e) not what you have gotten in Word, Look at the result carefully to get my mean Apr 25 at 6:36