1 Answer
1

I ran into this problem in 2009. I submitted it to WRI technical support. This is the reply I received.

After going through your notebook, I believe that what you observed is the
expected behavior of ToString. To elaborate:

When you use ToString[form], ToString prints out the string in the
OutputForm. Further this function to put everything sequentially and
therefore does not recognize that ALL the strings after \n should be placed
in a different line. Rather it just puts the string directly associated
with \n\n two spaces down and then resumes printing the later strings in
the same line.

The simplest way that you can remedy this issue is to use

ToString[form,TraditionalForm]

or

ToString[form, StandardForm]

both these options retain the original intended format.

Following this advice will give output that looks the way you want, but it may not be what you really want because it is not a simple string, but an interpretation box.

After receiving tech support's reply, I thought I might work around this by using Row instead of StringForm, but that didn't work. It gives the same output as you got with StringForm because, as the tech support reply implies, the problem lies in how ToString works and not with StringForm.

If you really want a simple string, I'm afraid you will have use Mathematica's string manipulation tools to build the string from component parts.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.