Newlines and Tabs in Strings
| \n | a newline (line feed) to be included in a string |
| \t | a tab to be included in a string |
Explicit representations of newlines and tabs in strings.
This prints on two lines.
| Out[1]= |  |
In
InputForm there is an explicit

to represent the newline.
Out[2]//InputForm= |
| |  |
Mathematica keeps line breaks entered within a string.
| Out[3]= |  |
There is a newline in the string.
Out[4]//InputForm= |
| |  |
With a single backslash at the end of a line,
Mathematica ignores the line break.
| Out[5]= |  |
You should realize that even though it is possible to achieve some formatting of Mathematica output by creating strings which contain raw tabs and newlines, this is rarely a good idea. Typically a much better approach is to use the higher-level Mathematica formatting primitives discussed in "String-Oriented Output Formats", "Output Formats for Numbers", and "Tables and Matrices". These primitives will always yield consistent output, independent of such issues as the positions of tab settings on a particular device.
In strings with newlines, text is always aligned on the left.
| Out[6]= |  |
The front end formatting construct
Column gives more control. Here text is aligned on the right.
| Out[7]= |  |
And here the text is centered.
| Out[8]= |  |