I use Mathematica for math lectures at my school. I would like to find a way to attach a secondary notebook to a primary notebook using AttachCell[]. The idea is to have picture-in-picture (PIP) functionality where the small picture is locked in place in the big picture.
I want to be able to scroll through the primary notebook (containing the text content of my lectures) while having a smaller secondary notebook (containing code and graphics content that I create on the fly) locked in a small window in the upper right-hand corner. This will allow me to focus on the lecture without having to scroll up and down to find a place to type in the code so it looks nice. This will allow me to create code and show graphics on the fly without messing up the flow of my text content in the primary notebook. Also, there are many times when I simply want to keep the same code and graphics on the screen while I progress through the lecture.
So far, my code below creates a docked cell with a button. When pressed it attaches a cell to the upper right-hand corner of the notebook. I included a button on that cell to delete itself when the PIP is no longer needed. Notice, that I used a rectangle as a placeholder for the secondary notebook. Below the code is an animation of my code illustrating the idea. The black rectangular area is where the secondary notebook should reside.
SetOptions[InputNotebook[], "WholeCellGroupOpener" -> True,
DockedCells ->
Cell[BoxData@
ToBoxes@
Button["Open Quick Notebook",
AttachCell[EvaluationNotebook[],
Style[
Grid[{{Button["Close Quick Notebook",
NotebookDelete[
Cells[EvaluationNotebook[], AttachedCell -> True]],
Appearance -> {"Palette"}]}, {Graphics[{Rectangle[]},
ImageSize -> 500]}}, Background -> LightGreen],
Deployed -> False], {Right, Top}, -20, {Right, Top}]],
"DockedCell"]]
The issue with Alexey's solution on macOS 12.3.1 running MM 13.0.1: The primary notebook scrolls upward on each keystroke inside the inputfield. See animation below.