Function Repository Resource:

NotebookOutlineMenu

Source Notebook

Create a dynamic menu that allows users to jump to specific sections in a notebook

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["NotebookOutlineMenu"][]

creates a menu that allows users to jump to specific sections in the current notebook.

ResourceFunction["NotebookOutlineMenu"][nb]

creates a menu that jumps to sections in the specified notebook.

ResourceFunction["NotebookOutlineMenu"][nb,label]

labels the menu with label.

ResourceFunction["NotebookOutlineMenu"][nb,label,styles]

shows cells with the specified style in the menu.

Details

ResourceFunction["NotebookOutlineMenu"] has the attribute HoldFirst, so a menu created with ResourceFunction["NotebookOutlineMenu"][InputNotebook[],] can be pasted into other notebooks and the menu will update accordingly.
The menu created by ResourceFunction["NotebookOutlineMenu"] updates automatically as sections are added or deleted from the notebook.
If nb is closed, the menu created by ResourceFunction["NotebookOutlineMenu"][nb,] will become disabled.
ResourceFunction["NotebookOutlineMenu"] accepts the same options as ActionMenu.

Examples

Basic Examples (4) 

Create a menu that lets you jump to any section in the current notebook:

In[1]:=
ResourceFunction["NotebookOutlineMenu"][]
Out[1]=

Create a menu for another notebook:

In[2]:=
nb = NotebookPut[Import["ExampleData/document.nb"]]
Out[2]=
In[3]:=
ResourceFunction["NotebookOutlineMenu"][nb]
Out[3]=

The menu becomes disabled if the notebook is closed:

In[4]:=
NotebookClose[nb]

Specify a label:

In[5]:=
ResourceFunction["NotebookOutlineMenu"][
 InputNotebook[], "Go to section\[Ellipsis]"]
Out[5]=

Control which cell styles are linked:

In[6]:=
ResourceFunction["NotebookOutlineMenu"][
 InputNotebook[], "Go to section\[Ellipsis]", {"Title", "Section"}]
Out[6]=
In[7]:=
ResourceFunction["NotebookOutlineMenu"][
 InputNotebook[], "Go to section\[Ellipsis]", "Input"]
Out[7]=

Scope (1) 

Customize the appearance of the menu:

In[8]:=
ResourceFunction["NotebookOutlineMenu"][InputNotebook[], Mouseover[
  Framed["Outline | \[EmptyDownTriangle]", RoundingRadius -> 3, Background -> LightBlue],
  Framed["Outline | \[FilledDownTriangle]", RoundingRadius -> 3, Background -> LightRed]
  ], Appearance -> None]
Out[8]=

Applications (2) 

Create a docked cell for a notebook that allows easy navigation to different sections:

In[9]:=
nb = NotebookPut[Import["ExampleData/document.nb"]]
Out[9]=
In[10]:=
SetOptions[nb, DockedCells -> {Cell[
    BoxData[ToBoxes[ResourceFunction["NotebookOutlineMenu"][nb]]]]}]

Get a notebook displaying information about system devices and add a notebook outline menu for quick navigation:

In[11]:=
info = SystemInformation["Devices", "GraphicsDevices"];
dc = Cell[BoxData[ToBoxes[ResourceFunction["NotebookOutlineMenu"][]]]];
nb = NotebookPut[
  ResourceFunction["AssociationNotebook"][info, DockedCells -> {dc}, "Title" -> "Graphics Devices"]]
Out[4]=

Properties and Relations (1) 

Menu item styles are inherited by the cells they link to:

In[12]:=
nb = NotebookPut[Notebook[
    First[Import["ExampleData/document.nb"]],
    StyleDefinitions -> FrontEnd`FileName[{"PresenterTools"}, "Sky.nb", CharacterEncoding -> "UTF-8"],
    DockedCells -> {Cell[
       BoxData[ToBoxes[ResourceFunction["NotebookOutlineMenu"][]]]]}
    ]];

Version History

  • 1.3.1 – 10 January 2022
  • 1.3.0 – 12 August 2020
  • 1.2.0 – 10 June 2020
  • 1.0.0 – 13 May 2020

Related Resources

License Information