WOLFRAM LANGUAGE TUTORIAL

Newlines and Tabs in Strings

na newline (line feed) to be included in a string
ta tab to be included in a string

Explicit representations of newlines and tabs in strings.

This prints on two lines.
In[1]:=
Click for copyable input
Out[1]=
In InputForm there is an explicit to represent the newline.
In[2]:=
Click for copyable input
Out[2]//InputForm=
The Wolfram Language keeps line breaks entered within a string.
In[3]:=
Click for copyable input
Out[3]=
There is a newline in the string.
In[4]:=
Click for copyable input
Out[4]//InputForm=
With a single backslash at the end of a line, the Wolfram Language ignores the line break.
In[5]:=
Click for copyable input
Out[5]=

You should realize that even though it is possible to achieve some formatting of Wolfram Language 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 Wolfram Language 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.
In[6]:=
Click for copyable input
Out[6]=
The front end formatting construct Column gives more control. Here text is aligned on the right.
In[7]:=
Click for copyable input
Out[7]=
And here the text is centered.
In[8]:=
Click for copyable input
Out[8]=