Mathematica Asked by user73765 on May 9, 2021
I have a very simple but annoying problem. Consider the following example:
Print["XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXX
XXXXXX XXXXXX XXXX X XXXXXXXXXXXXXX XXXX XXXX XXX XXXXXXXXXX XXXXXX
XXXXXXXXXXX XX XXXXXXXXXX XX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX
XXXXXXX XXXXXX"]
On my system, in a Mathematica notebook, the output looks on the screen as follows:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXX XXXXXX XXXXXX XXXX X
XXXXXXXXXXXXXX XXXX XXXX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXXXXX XX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXX XXXXXX
This of course changes when the windows size changes, but the point is that for some reason, the second line is much longer than the first, and it looks ugly and unnatural.
What I would like instead is to have something like:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXX XXXXXX XXXXXX XXXX X XXXXXXXXXXXXXX XXXX XXXX XXX
XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXXXXX XX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXX XXXXXX
with the first line being longer, and the full width of the window.
However, putting a new line at a particular position only solves this problem for a particular window size; when the window size changes, it no longer looks good. I want Mathematica to keep the first line longer than the second no matter what the window size is, and/or prevent it from splitting the string at an unnatural position.
Thanks in advance.
Input cells linebreak as math, while text cells linebreak as text. So, use:
Print @ TextCell["XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXX XXXXXX XXXXXX XXXX X XXXXXXXXXXXXXX XXXX XXXX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXXXXX XX XXX XXXXXXXXXX XXXXXX XXXXXXXXXXX XX XXXXXXX XXXXXX"]
to enforce text linebreaking.
Correct answer by Carl Woll on May 9, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP