I've been looking for a simple outliner for Mathematica notebooks and found Yuri E. Kandrashkin Sidebar'TOC, but decided I need something simpler and dynamic.
Has anyone tried making a dynamic outliner before?
I've been looking for a simple outliner for Mathematica notebooks and found Yuri E. Kandrashkin Sidebar'TOC, but decided I need something simpler and dynamic.
Has anyone tried making a dynamic outliner before?
This is what I've came up with so far:
Outline[] :=
CreatePalette[
Dynamic[Refresh[
Column@Cases[
NotebookRead /@
Cells[SelectedNotebook[],
CellStyle -> {"Section", "Subsection", "Subsubsection",
"Subsubsubsection"}],
Cell[name_,
style : "Section" | "Subsection" | "Subsubsection" |
"Subsubsubsection", ___, CellID -> id_, ___] :>
Button[StringRepeat["#",
Ceiling[(StringLength[style]/ 3)] - 2] <> " " <> name , (
NotebookFind[SelectedNotebook[], id, All, CellID];
SelectionMove[SelectedNotebook[], All, CellGroup];
FrontEndTokenExecute["OpenCloseGroup"];
), Appearance -> "Frameless"]], UpdateInterval -> 1]],
WindowSize -> {Fit, 550}, WindowFloating -> True, Saveable -> False,
WindowTitle -> (WindowTitle /.
AbsoluteOptions[SelectedNotebook[]])]
and here is how it looks in action (the section names are clickable):
I invite everyone who sees this as a useful little thing, to play with it/make it prettier/more useful or just accept it as a small community contribution.