Suppose that I have test1.nb and test2.nb in my local disk.

For simplicity, suppose that test1.nb consist of 1 line code


and for test2.nb, also 1 line code


Is it possible to create Hyperlink inside test1.nb, such that

  1. it leads to test2.nb
  2. the transition occurs in the same window + no change of window frame position and size
  3. the transition is smooth

I can create a Hyperlink satisfying 1. , 2..
I won't write all the code, but this is the outline :

store the frame information of test1.nb
close test1.nb
open test2.nb
adjust frame of test2.nb using the stored frame information

But for above method, the transition is not smooth, and the screen is flashing and tiring my eyes.
To elaborate, the transition did not actually happen in the same window frame.

I want to create Hyperlinks satisyfing even 3..

We've seen such smooth transition in help documentation.
But I don't want to borrow any part of code that constitutes the help documentation system.

With rather basic built-in command, I believe this can be done.

P.S. I am not insisting on the built-in command Hyperlink.
Anything that can perform the same function is welcome, in case the solution is not possible with Hyperlink.
And.. I have so many questions left to be asked for Hyperlink. Thank you very much!

  • $\begingroup$ What you could do is have a button that removes all the cells in test1.nb and inserts all the cells from test2.nb. Does that satisfy "it leads to test2.nb"? $\endgroup$
    – Jason B.
    Feb 6 at 23:39

1 Answer 1


Create two folders C:\\folder1 and C:\\folder2 and two files (notebooks) C:\\folder1\\test1.nb, C:\\folder2\\test2.nb with the following codes:

Notebook 1 contains:

Notebook 1
In[1373]:= 11!
Out[1373]= 39916800
In[1378]:= With[{file="C:\\folder2\\test2.nb"},Button["Open "<>file,NotebookPut[Import[file],InputNotebook[],Sequence@@Options[InputNotebook[],{WindowSize,WindowMargins}]];NotebookSave[InputNotebook[],file];]]
Out[1378]= Open C:\folder2\test2.nb

enter image description here

Notebook 2 contains:

Notebook 2
In[1371]:= 22!
Out[1371]= 1124000727777607680000
In[1377]:= With[{file="C:\\folder1\\test1.nb"},Button["Open "<>file,NotebookPut[Import[file],InputNotebook[],Sequence@@Options[InputNotebook[],{WindowSize,WindowMargins}]];NotebookSave[InputNotebook[],file];]]
Out[1377]= Open C:\folder1\test1.nb

enter image description here

Evaluate all input cells and save both notebooks, then close them.

Open one of the notebooks and by clicking on the button at bottom you can navigate between the notebooks.

Do not have both notebooks open at same time, because if you then click any button you would try to have two opened copies of the same notebook that Mathematica does not allow and you get a warning notification.

The cell group with the button can be closed by double-clicking on the output cell where the button is. After closing the group cell save the notebooks and the notebooks will look like this (without visible code that produces the button):

enter image description here

enter image description here


Alternatively without resaving of notebooks but with window closed and opened new one at the same position and same size:

With[{file = "C:\\folder2\\test2.nb"}, 
 Button["Open " <> file, 
   Sequence @@ Options[InputNotebook[], {WindowSize, WindowMargins}]];
  • $\begingroup$ Thank you, saving the document right after loading the document is a very good tricky idea. If there are no additional answers for some days, I will accept it. Note that a one big obstacle for ideal, improved Hyperlink feature has been solved : mathematica.stackexchange.com/questions/297619/… so I plan to go this way. $\endgroup$
    – imida k
    Feb 7 at 14:27

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.