Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there a way to open one notebook in two (or more) different windows? This can be helpful when working with a long notebook and one wants to edit one part of it while looking at a different part. Otherwise, you have to jump back and forth...

Edit: Per @Guillochon comment, splitting the window where the notebook is open is indeed a nice option.

Edit 2: Having a secondary "read-only" window can also be a nice compromise.

share|improve this question
2  
I like this question. I would expect the behavior to mirror (clone) the Notebook, such that a change in one is made to the other; optionally only one would be directly editable. I don't know how to do this but I'd like to find out. –  Mr.Wizard Aug 10 '12 at 8:10
2  
Isn't @Dror just asking for a split-screen window? Almost all modern text editors have that feature... –  Guillochon Aug 10 '12 at 8:20
    
@Guillochon Yes, but the mathematica interface is not a modern text editor:) All modern text editors have tab-indent as well, but try doing that in the notebook interface. I guess using Workbench is always an option, although I never got used to it... –  Ajasja Aug 10 '12 at 9:23
3  
I asked this split screen question to Wolfram in 1994! He tried and convince me I didn't need it. –  chris Aug 10 '12 at 9:28
1  
Tell us what you want and we ll explain to you why you don't need it! :-) The answer bellow works fine for me though. –  chris Nov 28 '13 at 10:44

1 Answer 1

up vote 24 down vote accepted

Here's a rather unsophisticated approach. The code below creates a toolbar in the current notebook, with buttons to create, refresh and close a replica notebook. The replica is given a gray background and cannot be edited or evaluated.

I tried to do something with Dynamic to automatically refresh the replica notebook, but without success.

Update

Here is a neater implementation. The code below creates a palette (which can be installed using the menu: Palettes/Install Palette) containing a single button to create a duplicate of the active notebook. The update button for the duplicate is now located in the duplicate itself, leaving the original notebook unchanged. The duplicate is closed using the normal window close button, but it has "ClosingSaveDialog" set to False so you won't get a save prompt.

CreatePalette[Button["Duplicate Active Notebook",
   NotebookPut[NotebookGet[InputNotebook[]] /. 
   {Rule[DockedCells, _] :> Sequence[], 
    Rule[WindowMargins, _] :> Rule[WindowMargins, {{0, Automatic}, {0, Automatic}}], 
    Cell[x___] :> Cell[x, Evaluatable -> False]}, 
    Background -> GrayLevel[0.95], Editable -> False, "ClosingSaveDialog" -> False, 
    DockedCells -> With[{sourcenb = InputNotebook[]}, 
      Cell[BoxData[ToBoxes[Button["Update", 
          SelectionMove[InputNotebook[], All, Notebook]; 
          NotebookWrite[InputNotebook[], 
           NotebookGet[sourcenb] /. Cell[x___] :> Cell[x, Evaluatable -> False]]]]],
       "DockedCell", CellContext -> Cell]],
    WindowTitle -> "Duplicate of " <> AbsoluteOptions[InputNotebook[], WindowTitle][[1, 2]]];
   SetSelectedNotebook[InputNotebook[]]], WindowTitle -> "Duplicate"];
share|improve this answer
    
+1 Great idea. I did notice that syntax highlighting doesn't work, which is a big minus. –  Ajasja Aug 10 '12 at 13:58
    
@Ajasja: That's not quite right; There is some degree of highlighting. For example internal variables of modules - do get colored in green. –  Dror Aug 10 '12 at 14:41
    
@SimonWoods: The Close toolbar doesn't work for me - I get SetOptions::optnf: DockedCells is not a known option for thisnb. >> error. Any idea? –  Dror Aug 10 '12 at 14:44
1  
@Dror, see update. –  Simon Woods Aug 21 '12 at 21:56
3  
@Dror, It sounds like you have installed the notebook containing the CreatePalette code, rather than the palette it creates. Open a fresh notebook, paste my code into it and execute it. This should create a palette window titled "Duplicate" at the top right of the screen. You can now close the notebook window - you don't need to save it, the code has done its job. Now go to Palettes/Install Palette on the menu, select "Duplicate" as the Source and provide an install name (e.g. Duplicate). Then click Finish. You should now have the new item in the Palette menu. –  Simon Woods Aug 22 '12 at 7:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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