# How can I copy the cell as LaTeX code but the look remains as what I typed?

I typed this on Mathematica.

Subscript[a, 0] = 1/2 \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n\ odd$$, $$\[Infinity]$$]
\*FractionBox[$$8 A$$,
SuperscriptBox[$$(n\ \[Pi])$$, $$2$$]]\) = 1/2 (8 A)/\[Pi]^2 \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n\ odd$$, $$\[Infinity]$$]
\*FractionBox[$$1$$,
SuperscriptBox[$$n$$, $$2$$]]\) = 1/2 (8 A)/\[Pi]^2 \[Pi]^2/8 = (A/2)


Or the raw input form:

Subscript[a, 0] = (1/2)*Sum[(8*A)/(n*Pi)^2, {n*odd, Infinity}] =
(1/2)*((8*A)/Pi^2)*Sum[1/n^2, {n*odd, Infinity}] =
(1/2)*((8*A)/Pi^2)*(Pi^2/8) = A/2


And then I copy the cell as LaTeX I got this:

a_0=\frac{1}{2} \sum _{n \text{odd}}^{\infty } \frac{8 A}{(\pi  n)^2}=\frac{(8 A) \sum _{n \text{odd}}^{\infty } \frac{1}{n^2}}{2 \pi ^2}=\frac{\pi ^2 (8 A)}{2 \pi ^2 8}=\frac{A}{2}


However, if I display this LaTeX code I get a different look with the one I typed above.
Not that the numerator and demoninator are combined.
How can I copy the cell as LaTeX code but the look remains as what I typed?

That is expected due to internal transformation and automatic expression rewriting. Since you are using this for display only, you can add

\[CenterDot]


between the terms you do not want combined which will now give this Latex

Subscript[a, 0] = 1/2 \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n\ odd$$, $$\[Infinity]$$]
\*FractionBox[$$8 A$$,
SuperscriptBox[$$(n\ \[Pi])$$, $$2$$]]\) =
1/2 (8 A)/\[Pi]^2 \[CenterDot]\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n\ odd$$, $$\[Infinity]$$]
\*FractionBox[$$1$$,
SuperscriptBox[$$n$$, $$2$$]]\) =
1/2 \[CenterDot](8 A)/\[Pi]^2 \[CenterDot]\[Pi]^2/8 = (A/2)


Screen shot

I do not know of another way to prevent this. If you can find something better than \[CenterDot] you can try it. This gets transformed to \cdot in Latex.

\[CenterDot] is in basic typesetting palettes. Under operators

• thanks, that is nice. \[CenterDot]  work but Dot doesn't. Would be faster to type Dot than \[CenterDot] .
– hana
Commented Apr 5, 2022 at 20:48
• @hana you can use Palettes to enter it. One click only. Commented Apr 5, 2022 at 20:55
• The answer is great but I just wonder if there is some way to automate this? Assume that I have more than 300 expressions so it would be really slow to manually input the center dot.
– hana
Commented Apr 6, 2022 at 5:32