A context unique to each group at a certain level

Recent versions of Mathematica provide a unique $Context option for each group of cells through:

  • Rating> Notebook default context> Unique for each cell group

This is an attractive concept, but I find it unsuitable because my code spans several groups of cells.

I would like to specify a unique context for groups of cells of a certain level, for example, each Section , but not a separate context for each Subsection or Subsubsection .

The decision will have to influence new groups of cells as they are created.

+6
source share
2 answers

You must do this by changing the stylesheet of your laptop. You can use the CellContext option to set the context. The mma documentation does this to limit the context of the context for cell groups.

+1
source

You can achieve this by grouping cells manually instead of relying on the automatic grouping mechanism. In the notebook in question, use the "Cell / Grouping / Manual Grouping" element to enable manual grouping. Now, when you enter sections, subsections, etc., they will not be grouped automatically. Select the cells that should be in the same group and use the menu item Cell / Group / Group cells / Group together. Now that they are grouped, you can set CellContext as a CellGroup, and they will all fit together well.

+1
source

Source: https://habr.com/ru/post/887367/


All Articles