How does one print text without unnecessary line returns?

I am using the command:

Print[“A paragraph goes in here; a subparagraph goes here; etc.”]

The output text has line returns that differ from where they are in the input text. How can I make the output text look just like the input text? And with a more readable font than the mma default?

=================

1

 

Is this what you want: Style[“A paragraph goes in here; \na subparagraph goes here; \netc.”, FontFamily -> “Courier”]? $FontFamilies gives the list of available fonts.
– corey979
Sep 14 at 19:09

2

 

In general, Print is not the right command if you want to produce nicely formatted output. It’s more for diagnostic purposes. Are you insisting on using Print?
– Jens
Sep 14 at 19:15

  

 

I am not insisting on using Print. What is the right command?
– Michael B. Heaney
Sep 14 at 20:52

=================

2 Answers
2

=================

If you need strict control on the appearance of the output, you could consider using CellPrint which gives you maximum flexibility.

For example, you can print a cell with style “Text”:

CellPrint@TextCell[“A paragraph goes in here; a subparagraph goes here; etc.”, “Text”]

You can print a cell with specific formatting:

CellPrint[TextCell[
Row[{“The equation “, ExpressionCell[TraditionalForm[x^2 == -1]], ” has 2 solutions.”}],
“Text”]]

I refer you to the Documentation pages for ExpressionCell, TextCell and CellPrint for additional examples.

Print just displays the given text. Style allows to format the text in a variety of styles, e.g.

Style[“A paragraph goes in here; \n a subparagraph goes here; \n etc.”,
Blue, 24, Italic, FontFamily -> “Courier”, LineSpacing -> {1, 0}]

A line break is introduced with \n, and the list of available fonts can be obtained with $FontFamilies. For an exhausting list of possibilities achievable, see the documentation for Style.

  

 

Thanks for your help. I applied your suggestion like so:
– Michael B. Heaney
Sep 14 at 21:11

  

 

Style[“Location classifications; \n 1 = Openings that users will \ touch frequently: buttons, usb jack, audio jack, charging ports, \ etc.; \n 2 = Openings or seams that users will touch infrequently: \ speaker holes, microphone openings, housing/mating seams, etc.; \n 3 \ = The screen; \n 4 = Surfaces: the back of the device, etc.”, Black, \ 14, Plain, FontFamily -> “Arial”, LineSpacing -> {1.5, 0}]
– Michael B. Heaney
Sep 14 at 21:12

  

 

But the line still breaks unnecessarily between the words “touch” and “infrequently”???
– Michael B. Heaney
Sep 14 at 21:13

2

 

For future cases: (1) don’t extend the scope of the initial question in the comments; edit the question accordingly or post a new one; (2) don’t make prolonged discussions in the comments; (3) when posting MMA code in the comments, enclose it in the grave accents, `, that you can find in the upper left part of the keyboard.
– corey979
Sep 14 at 22:42

1

 

@Michael With the option setting LineBreakWithin -> False for Style there will be no extra line breaks, even if the with of the window is to small to display the lines completely. One can use Pane for more options (size, scrolling, scrollbars, magnification, …). From you question it is not clear how the output should look like and how it’s related to the TableHeadings in your answer.
– Karsten 7.
Sep 15 at 11:11