0
$\begingroup$

Suppose we have a Section, Subsection and Subsubsection cell grouped automatically, as in the gif below. I can programmatically open the Subsection Cell using the code in the gif.

enter image description here

If the section cell is closed then the Subsection and subsubsection cells are not visible. However, when I apply the code, the cells open and are visible. This is what I mean by opening a group "explicitly". I do not want this.

Is it possible to open a group and that's all it does? I do not want to necessarily show it. I call this opening a group "implicitly". I know I can programmatically close the Section cell again. But I have many cell types and large notebooks, with many different levels of subgroups so this method is going to be a difficult puzzle. I'd like an easier method.

Is there some feature that allows me to open a subgroup (and not necessarily see it being opened)? It seems like this should be a feature as I'm asking for the bare minimum... just to open a group.

$\endgroup$
1
$\begingroup$

Since everything in Mathematica is an expression, all we need to do for these types of operations is to check the output of NotebookGet[InputNotebook[]] and see what replacements should be done.

For this problem you can try executing this:

NotebookPut[NotebookGet[InputNotebook[]] /. 
  CellGroupData[{Cell[x___, "Subsection", y___], z___}, Closed] :> 
    CellGroupData[{Cell[x, "Subsection", y], z}, Open],InputNotebook[]]
$\endgroup$
  • $\begingroup$ Thank you, however this solution creates a new notebook with the feature requested. However, I need a solution that does this in the existing notebook. My notebook involve docked cells and hyperlinks... so its not going to work creating a new notebook. It seems like there must be a simple way. Ideas? $\endgroup$ – Michael McCain Oct 16 '16 at 7:12
  • $\begingroup$ Fixed it. Now it overwrites the current one $\endgroup$ – dan7geo Oct 16 '16 at 7:14
  • $\begingroup$ Thank you. hmmm... it seems to work... however, it's batting about 50% breaking Mathematica forcing me to restart. Strange. $\endgroup$ – Michael McCain Oct 16 '16 at 7:25
  • $\begingroup$ If there is a way to do this without creating a new notebook it would help me a lot. However, if this is the only way... then I'll make do. Thank you. $\endgroup$ – Michael McCain Oct 16 '16 at 7:26
  • 1
    $\begingroup$ Ideally you should do this in a different notebook and replace the InputNotebook[] with the path to the actual notebook. This might fix the problems $\endgroup$ – dan7geo Oct 16 '16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.