4
$\begingroup$

Some programs like LibreOffice or Microsoft Word provide a way to open a second window (or even a third one) to an already open document. The function in question is located there at Window>New Window.

These programs let one open two or more views into the same document at different places, e.g. to compare what is said at one place with what is said at the other one. You can easily switch between different parts of a large document and manage several "working places" without loosing focus by opening independent windows at the places where you work or check things.

Of course editing is possible in multiple such instances. You can e.g. correct a typo in any window open in the same document. If views overlap with respect to the document, you see the changes happening in parallel to the other views as well.

For Mathematica a use case would be to independently scroll through some code and the output which it has generated – but many pages below from where it actually is programmed (e.g. if the code is armed with some conditional print statements which lets you check the flow of control).

$\endgroup$
4
  • 1
    $\begingroup$ Multiple, concurrent views are not currently supported. $\endgroup$
    – ihojnicki
    Commented May 29, 2021 at 11:43
  • $\begingroup$ Is it possible, to direct all output to another notebook such that one can at least do what I want in such a way? $\endgroup$ Commented May 29, 2021 at 12:27
  • $\begingroup$ If you can actually do that with Microsoft Word, this is certainly a new feature to learn of for me. I know such things are possible with cloud hosted utilities like Google docs & the-like. Perhaps something like that may inevitably be possible with wolfram technology! $\endgroup$ Commented May 29, 2021 at 17:43
  • $\begingroup$ To direct output to another notebook, there are a whole set of notebook and cell operations which you can read in the Documentation Center. That'll help, I am sure. Not only the output, you can also transfer the input codes to another notebook. I think that reading the documentation can help expand your imagination. $\endgroup$
    – 梁國淦
    Commented Jun 1, 2021 at 1:54

1 Answer 1

2
$\begingroup$

Here is a method that uses two notebooks sharing the same kernel to achieve the desired effect of scrolling through different sections of code and output. Try this in a new Mathematica session. Open a new notebook, called the Code Notebook, and enter these lines

ClearAll["Global`*"]

data = RandomReal[3, 10];
plot = ListPlot[data, PlotStyle -> Red, ImageSize -> Small];

Open a second new notebook, called the "Output Notebook", and enter these lines

Dynamic[data]
Dynamic@GraphicsRow@
  {ListPlot[data, ImageSize -> Small, 
    PlotRange -> {All, {0, 5}}],
   plot}

Evaluate the Code NB first and then evaluate the Output NB. Now go back and evaluate the Code NB a few more times and watch how the Output changes.

Imagine the Code NB has many pages of code and the Output NB shows selected output from various sections of the Code. We can scroll and edit in either window.

One drawback of this method is the scroll state of the Output NB is not locked. It can change when we, for example, change the number of the data points from 10 to 1000 and back. This can be overcome in a number of ways. One way is to use multiple output notebooks. Another is use Dynamic[Dataset@data] instead of Dynamic[data].

Depending on what changes are made in the Code NB, the entire Code NB may require evaluation. If you quit the kernel, both the Code NB and the Output NB(s) should be re-evaluated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.