Skip to main content
added 199 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

StandardForm does not support tabs or newlines like regular text editor. It doesn't make sense to do so considering variety of 2D typesetting available there.

One can't even type \t unless it is a beginning of the line.

tutorial / NewlinesAndTabsInStrings:

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 [...Column etc]. These primitives will always yield consistent output, independent of such issues as the positions of tab settings on a particular device.

And Print output is sent via $Output which FormatType is set to StandardForm.

In practice this means that your input goes through Cell @ BoxData @ ToBoxes @ input (roughly).

From what I've tried only TextForm respects tabs. It is used in styles like Code / Program / Text etc. Those cells contain TextData or just plain string inside instead of BoxData.

So the quick fix is:

Print @ TextCell["1\t55\n33\t44"]

or

Print @ RawBoxes @ Cell["1\t55\n33\t44"]

By the way, what documentation meant by "higher-level Wolfram Language formatting primitives" is something like:

Print @ Grid[ImportString["a\t55\n33\t44", "Table"], Alignment -> Left]

StandardForm does not support tabs or newlines like regular text editor. It doesn't make sense to do so considering variety of 2D typesetting available there.

One can't even type \t unless it is a beginning of the line.

tutorial / NewlinesAndTabsInStrings:

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 [...Column etc]. These primitives will always yield consistent output, independent of such issues as the positions of tab settings on a particular device.

And Print output is sent via $Output which FormatType is set to StandardForm.

In practice this means that your input goes through Cell @ BoxData @ ToBoxes @ input (roughly).

From what I've tried only TextForm respects tabs. It is used in styles like Code / Program / Text etc. Those cells contain TextData or just plain string inside instead of BoxData.

So the quick fix is:

Print @ TextCell["1\t55\n33\t44"]

or

Print @ RawBoxes @ Cell["1\t55\n33\t44"]

StandardForm does not support tabs or newlines like regular text editor. It doesn't make sense to do so considering variety of 2D typesetting available there.

One can't even type \t unless it is a beginning of the line.

tutorial / NewlinesAndTabsInStrings:

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 [...Column etc]. These primitives will always yield consistent output, independent of such issues as the positions of tab settings on a particular device.

And Print output is sent via $Output which FormatType is set to StandardForm.

In practice this means that your input goes through Cell @ BoxData @ ToBoxes @ input (roughly).

From what I've tried only TextForm respects tabs. It is used in styles like Code / Program / Text etc. Those cells contain TextData or just plain string inside instead of BoxData.

So the quick fix is:

Print @ TextCell["1\t55\n33\t44"]

or

Print @ RawBoxes @ Cell["1\t55\n33\t44"]

By the way, what documentation meant by "higher-level Wolfram Language formatting primitives" is something like:

Print @ Grid[ImportString["a\t55\n33\t44", "Table"], Alignment -> Left]
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

StandardForm does not support tabs or newlines like regular text editor. It doesn't make sense to do so considering variety of 2D typesetting available there.

One can't even type \t unless it is a beginning of the line.

tutorial / NewlinesAndTabsInStrings:

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 [...Column etc]. These primitives will always yield consistent output, independent of such issues as the positions of tab settings on a particular device.

And Print output is sent via $Output which FormatType is set to StandardForm.

In practice this means that your input goes through Cell @ BoxData @ ToBoxes @ input (roughly).

From what I've tried only TextForm respects tabs. It is used in styles like Code / Program / Text etc. Those cells contain TextData or just plain string inside instead of BoxData.

So the quick fix is:

Print @ TextCell["1\t55\n33\t44"]

or

Print @ RawBoxes @ Cell["1\t55\n33\t44"]