8

We can control the page width used by InputForm by applying SetOptions to "stdout":

SetOptions["stdout", PageWidth -> 10];
Range[5] // InputForm
{1, 2, 3, 
4, 5}

But addition of the line

SetOptions["stdout", PageWidth -> 125];

to the Kernel "init.m" file has no effect. How is it possible to change the default page width used by InputForm?

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • Try also adding Internal\NewInput=False;toinit.m`. – ilian Jul 18 '15 at 15:57
  • 1
    @ilian This does not work: SetOptions["stdout", PageWidth -> 125]; inside init.m does not change the PageWidth setting: Options["stdout", PageWidth] returns {PageWidth -> 32} after launching Mathematica. – Alexey Popkov Jul 18 '15 at 16:14
  • 1
    Did you add both SetOptions["stdout", PageWidth -> 125]; and Internal\NewInput=False;`? – ilian Jul 18 '15 at 16:16
  • @ilian, I added both and it did not work, maybe Alexey had better luck. – bobbym Jul 18 '15 at 16:58
  • 1
    Interesting, it did work for me (V10.2 on Linux). Maybe there is something OS-specific. Another idea: task := SetOptions["stdout", PageWidth -> 125]; RunScheduledTask[task, {1}]. – ilian Jul 18 '15 at 17:02
  • Hi ilian; I am running Linux Mint 17.1 with 10.2 Running task := SetOptions["stdout", PageWidth -> 125]; RunScheduledTask[task, {1}] changes the PageWidth to 125 but does not do the same for the OP's example of 10. – bobbym Jul 18 '15 at 17:50
  • @ilian Yes, I tried both SetOptions["stdout", PageWidth -> 125]; and Internal`NewInput=False; inside init.m (at the same time), I have also tried task := SetOptions["stdout", PageWidth -> 125]; RunScheduledTask[task, {1}] inside init.m. Unfortunately both methods do not work and Options["stdout", PageWidth] still returns {PageWidth -> 32} after launching Mathematica. I'm with MMa 10.2 on Win7 x64. With MMa 8.0.4 the situation is the same. – Alexey Popkov Jul 18 '15 at 17:56
  • 1
    (I think) I see, what I had suggested applies to the standalone kernel... the frontend will tell the kernel to set PageWidth to WindowWidth and also change it dynamically on window resize. Perhaps SetOptions[$FrontEnd, {PrivateEvaluationOptions -> {"OutputFormPageWidth" -> 125}}] will do the trick? – ilian Jul 18 '15 at 19:44
  • That works fine for me. – bobbym Jul 19 '15 at 08:13

1 Answers1

9

What I think is happening is that the SetOptions statement in init.m is executed during kernel initialization as expected, however when the notebook window is opened, the front-end sets PageWidth to be WindowWidth. Furthermore, the kernel value does get changed accordingly whenever the window is resized.

This being the front-end, I would not be surprised if there are other/better ways, but what seemed to work was

SetOptions[$FrontEnd, PrivateEvaluationOptions -> {"OutputFormPageWidth" -> 125}]

While it was not the culprit in this question, I would still mention that something similar may happen in a console kernel session, where PageWidth can be reset by the terminal input library to be the width of the console at startup time. This can be avoided by either turning the terminal library off or using a scheduled task in init.m, e.g.

task := SetOptions["stdout", PageWidth -> 125]; 
RunScheduledTask[task, {1}]

so that it runs after the terminal library is loaded.

ilian
  • 25,474
  • 4
  • 117
  • 186