# Formatting problem

Writing:

"x =" <> ToString[1/2]


I get:

and even if I tried in the forum I could not find a way to get rid of this problem, namely to obtain:

or better still:

Thank you!

Last formatting problem. Writing:

"x =" TextForm[1/2 q (l - 2 \[Xi])]


I get:

where the outer bracket is completely useless. Is it possible to remove it?

• What are you looking to get? – Vsevolod A. Feb 11 '18 at 10:12
• @VsevolodA.: I modified the request, thank you! – TeM Feb 11 '18 at 10:15
• Try "x =" TextForm[1/2] – Vsevolod A. Feb 11 '18 at 10:17

"x = " <> ToString[1 / 2, StandardForm]  (* or *)
Row[{"x = ", StandardForm[1/2]}]


"x =" <> ToString[1/2 q (l - 2 \[Xi]), StandardForm] (* or *)
Row[{"x =", StandardForm[1/2 q (l - 2 \[Xi])]}]


You can use TraditionalForm in place of StandardForm above to get similar outputs.

• This strategy, in effect, solves all my problems above. Thank you! – TeM Feb 11 '18 at 10:56
• @TeM, my pleasure. Thank you for the accept. – kglr Feb 11 '18 at 10:58

Something like ToString["x =" TextForm[1/2]] produces a 3 string with text formatted as necessary, if that's what you are looking for.

• Please note that the output is text and it's poorly formatted i.e. division is made with "-" placed between strings with 1 and 2. – Vsevolod A. Feb 11 '18 at 10:22
• Thanks to your help I managed to get what you wanted, i.e. copying what you wrote and placing "StandardForm" instead of "TextForm". I posed a last problem. Could you give us an eye, please? Thank you! – TeM Feb 11 '18 at 10:50